The Five Core Rules
Double Quotes Only
All strings and keys must use double quotes (")
No Trailing Commas
The last item in an object/array must not have a comma after it
No Comments
Standard JSON does not support // or /* */ comments
UTF-8 Encoding
JSON documents must be encoded in UTF-8
Single Root Value
A JSON document must have exactly one root value (object, array, or primitive)
Strings & Quoting Rules
Every string in JSON — both keys and values — must be enclosed in double quotes. This is the most common source of errors for developers coming from JavaScript or Python.
Valid vs Invalid Quoting
Valid
{ "name": "John" }{ "age": 30 }{ "items": ["a", "b"] }Invalid
{ 'name': 'John' } // single quotes{ name: "John" } // unquoted key{ "name": John } // unquoted valueEscape Sequences
Special characters inside strings must be escaped with a backslash:
| Sequence | Character | Example |
|---|---|---|
| \" | Double quote | "He said \"hello\"" |
| \\ | Backslash | "C:\\Users\\file" |
| \n | Newline | "Line 1\nLine 2" |
| \t | Tab | "Col1\tCol2" |
| \r | Carriage return | "Windows\r\n" |
| \/ | Forward slash | "path\/to\/file" |
| \b | Backspace | Rarely used |
| \f | Form feed | Rarely used |
| \uXXXX | Unicode | "Heart: \u2764" |
Commas & Separators
Commas separate items in objects and arrays. The rules are simple but strict:
1{2 "name": "Alice",3 "age": 30,4 "hobbies": ["reading", "coding", "hiking"]5}No Trailing Commas
{"a": 1, "b": 2,} ← INVALID (trailing comma)Whitespace & Formatting
Whitespace between JSON tokens is insignificant. These two documents are identical:
{ "name": "Alice", "age": 30}{"name":"Alice","age":30}Use pretty-printed JSON for readability during development, and minified JSON for production APIs and data transfer to reduce bandwidth.
Top 10 Syntax Mistakes
Using single quotes
Always use double quotes for strings and keys
Trailing comma after last item
Remove the comma after the final element
Adding comments (// or /* */)
JSON does not support comments
Unquoted keys
All object keys must be double-quoted strings
Using undefined
Use null instead — undefined is not valid JSON
Leading zeros on numbers
007 is invalid; use 7 instead
Literal newlines in strings
Use \n escape sequence instead
Using NaN or Infinity
These are not valid JSON values — use null or a string
Unescaped backslashes
Use \\ to represent a literal backslash
Multiple root values
A JSON document must have exactly one root value
Try It Yourself
This JSON has three deliberate errors. Can you fix them all? Click Run & Validate to check.
Try It Yourself
Fix the three syntax errors to make this valid JSON