Option bom

Table of Contents

The bom option strip the byte order mark (BOM) from the input string or buffer. When activated, the BOM is automatically detected and the parsing will occur whether a BOM was found or not.

  • Type: boolean
  • Optional
  • Default: false
  • Since: 4.4.0

About

The UTF-8 BOM is a sequence of Bytes at the start of a text-stream (EF BB BF) that allows the reader to more reliably guess a file as being encoded in UTF-8.

Example

It is a boolean value which default to false. The bom example simply activate the option:

const parse = require('csv-parse/lib/sync')
const assert = require('assert')

const data = "\ufeffa,b,c\n"
const records = parse(data, {
  bom: true
})
assert.deepEqual(records, [
  [ 'a', 'b', 'c' ]
])