Format and validate JSON
Paste JSON to format and validate it. Errors report the exact line and column.
JSON formatter
Formats as you type. Nothing is uploaded.
- Size
- —
- Keys
- —
- Depth
- —
What JSON allows, and what it does not
JSON is a much smaller language than the JavaScript it came from, and almost every parse error is a JavaScript habit leaking into it:
- Trailing commas —
{"a": 1,}is invalid. JavaScript allows it; JSON does not. - Single quotes —
{'a': 1}is invalid. Strings and keys must use double quotes. - Unquoted keys —
{a: 1}is invalid. Every key is a quoted string. - Comments — no
//or/* */. Use JSONC or JSON5 if you need them. - undefined, NaN, Infinity — none of these exist in JSON. Use
null. - Leading zeros and hex —
0x1Fand007are both invalid numbers.
A single trailing comma accounts for a surprising share of all JSON errors, because it is invisible when you are scanning for something structural.
Common questions
Why is my JSON invalid when it looks fine?
The three most common causes are a trailing comma after the last item in an object or array, single quotes instead of double quotes, and unquoted keys. All three are legal in JavaScript and illegal in JSON, which is why they slip past so easily when you copy an object out of code.
What do the line and column numbers mean?
They point at the first character the parser could not make sense of. The real mistake is often just before that point — a missing comma on the previous line shows up as an error on the next one. Read the line above the reported one before assuming the parser is confused.
Does JSON allow comments?
No. The JSON specification has no comment syntax, so // and /* */ both cause a parse error. Formats that accept comments, such as JSONC or JSON5, are supersets used by tools like VS Code for config files, and they need a different parser.
What counts as the depth?
Depth is how many levels of nesting the deepest value sits at. A flat object is depth 1; an object containing an object is depth 2. It is useful as a quick check that a structure matches what an API documented, and as a warning that something has grown harder to work with than it should be.
Is my JSON sent anywhere?
No. Parsing and formatting use your browser's own JSON engine and run entirely on your machine. Nothing is uploaded, logged, or stored — which matters, because pasted JSON so often contains API keys, tokens, or personal data.