The Strict Rules of RFC 8259 JSON
JavaScript Object Notation (JSON) is the universal data format for web APIs, configuration files, and state management. However, many developers accustomed to forgiving JavaScript syntax run into syntax errors when dealing with strict JSON parsers.
Top 4 Syntax Gotchas That Break JSON Parsing
- Trailing Commas: Unlike JavaScript objects, JSON forbids trailing commas.
{"a": 1, "b": 2,}will throw an immediate parsing error. - Single Quotes: All keys and string values in JSON must be wrapped in double quotation marks (
"key": "value"). Single quotes ('key': 'value') are invalid. - Unquoted Keys: Object keys in JSON cannot be bare identifiers.
{id: 101}is invalid; it must be{"id": 101}. - Comments: Standard JSON does not support inline comments (
// commentor/* comment */).
Reading Line & Column Syntax Errors
When you paste 2,000 lines of minified JSON from a server log into WebUtilities's JSON Formatter, the parser detects the precise character index where the token stream failed and points you directly to the offending line and column number.
Try the Related Tools:
JSON Formatter and Validator
Format, validate, and minify JSON data with precise line/column syntax error detection.
CSV to JSON and JSON to CSV Converter
Convert data between CSV and JSON with support for quoted strings, custom delimiters, and Unicode.
Base64 Text Encoder and Decoder
Encode plain text to Base64 and decode Base64 back to text with full UTF-8 Unicode support.