UTF-8 BOM before a JSON document
A byte order mark (EF BB BF) at the start of the file. Windows editors, Excel exports and PowerShell's `Out-File` add one by default. RFC 8259 says a JSON text must not begin with a BOM.
The input
{"a": 1}{"a": 1}How to fix it
Save the file as UTF-8 without BOM. In PowerShell use `Set-Content -Encoding utf8NoBOM`; in Notepad choose 'UTF-8' rather than 'UTF-8 with BOM'.
The tell is an error at position 0 on a file that looks perfectly fine in your editor — the BOM is invisible. Check with `head -c 3 file.json | xxd`.
What each parser reports
Every message below was captured by running this exact input through the parser named. 17 of 21 parsers rejected it; 4 accepted it.
| Parser | Exact message |
|---|---|
| CPython json.loads CPython 3.12.3 | Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)what this message means → |
| encoding/json Unmarshal Go go1.22.2 | invalid character 'ï' looking for beginning of valuewhat this message means → |
| Gson Java 21.0.12 | accepted — no error |
| Gson JsonParser (lenient off) Java 21.0.12 | accepted — no error |
| hjson Node.js 22.22.2 | accepted — no error |
| Jackson ObjectMapper Java 21.0.12 | Unexpected character ('?' (code 65279 / 0xfeff)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')what this message means → |
| JavaScriptCore JSON.parse JavaScriptCore (Bun 1.4.1) | JSON Parse error: Unrecognized token ''what this message means → |
| json-bigint Node.js 22.22.2 | Unexpected '' |
| JSON5 Node.js 22.22.2 | accepted — no error |
| JSON::PP Perl 5.038002 | malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "\x{ef}\x{bb}\x{bf}{"...")what this message means → |
| json_decode PHP 8.3.6 | Syntax error |
| Newtonsoft.Json JsonConvert Newtonsoft.Json 13.0.3 on .NET 8.0.30 | Unexpected character encountered while parsing value: . Path '', line 0, position 0.what this message means → |
| Newtonsoft.Json JsonTextReader Newtonsoft.Json 13.0.3 on .NET 8.0.30 | Unexpected character encountered while parsing value: . Path '', line 0, position 0.what this message means → |
| orjson CPython 3.12.3 | UTF-8 byte order mark (BOM) is not supported: line 1 column 1 (char 0)what this message means → |
| Ruby JSON.parse Ruby 3.2.3 | unexpected token at '{"a": 1}' |
| serde_json::from_str Rust (serde_json 1.x) | expected value at line 1 column 1what this message means → |
| SpiderMonkey JSON.parse SpiderMonkey 115 | JSON.parse: unexpected character at line 1 column 1 of the JSON datawhat this message means → |
| System.Text.Json Deserialize .NET 8.0.30 | '0xEF' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.what this message means → |
| System.Text.Json JsonDocument .NET 8.0.30 | '0xEF' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.what this message means → |
| ujson CPython 3.12.3 | Expected object or value |
| V8 JSON.parse Node.js 22.22.2 | Unexpected token '', "{"a": 1}" is not valid JSONwhat this message means → |
What the specification says
The exact sections that govern this error. Descriptions are our paraphrase; follow the links for the normative text.
| Body | Section |
|---|---|
| IETF | JSON exchanged outside a closed ecosystem must be encoded in UTF-8. The section also states that implementations must not add a byte order mark, while parsers may choose to ignore one. |
| IETF | The encoding RFC 8259 §8.1 requires for JSON exchanged between systems. |
| Unicode Consortium | Normatively referenced by RFC 8259 for the definition of a character. |
Other errors in this category
Curly (smart) quotes in JSON
Typographic quotes U+201C and U+201D instead of the ASCII double quote. Produced by word processors, chat clients, Google Docs and…