JSON Formatter & Validator
- 57 tools
- No watermark
- No daily limit
Paste JSON to format or minify it. Indent with tabs or 2, 4, or 8 spaces. If parsing fails, you get the exact line and column, not just a character offset. We use a background thread for large files so your browser stays responsive.
What the error messages actually mean
| What you see | What it usually is |
|---|---|
Unexpected token } | A trailing comma before the closing brace. JSON does not allow one. |
Unexpected token ' | Single quotes. JSON strings use double quotes, always. |
Unexpected token / | A comment. JSON has none. That is JSONC or JSON5. |
| Unexpected end of input | A brace or bracket never closed, often because the file was truncated. |
Unexpected token N | NaN or Infinity, which JSON cannot represent. |
| Unexpected non-whitespace after JSON | Two documents in one file, or a stray character after the final brace. |
Chrome reports many of these without a position at all. This tool recovers the line and column from the quoted excerpt, so you get somewhere to look rather than a character offset into a file you cannot count through.
Choosing an indent
| Indent | Where it is the convention |
|---|---|
| 2 spaces | npm, most JavaScript tooling, the majority of API examples |
| 4 spaces | Python projects, .NET configuration, many corporate style guides |
| Tab | Go projects, and anywhere the file is read at several zoom levels |
| Minified | Anything sent over a network: whitespace is bytes |
None of this changes the data. Two JSON documents that differ only in whitespace are the same document, which is why minifying before sending and formatting before reading costs nothing.
What JSON deliberately leaves out
Most invalid JSON is valid JavaScript, which is the root of the confusion. The format is a strict subset on purpose. Every omission removes an ambiguity between parsers.
- No comments. There is no agreed way to preserve them, so round-tripping a file would silently lose them.
- No trailing commas. Some parsers ignored them and some counted an extra empty element.
- No single quotes, and keys must be quoted.
- No
NaN,Infinityorundefined. Usenull, or a string if the distinction matters.
If you want the conveniences, JSON5 and JSONC exist and have their own parsers. What you cannot do is feed them to something expecting JSON.
Frequently asked questions
Is my JSON uploaded to a server?
No. Parsing and formatting happen in your browser. The site’s security policy sets connect-src ‘none’, so the browser blocks network requests from these pages. You can confirm it in the Network tab.
Why does Chrome sometimes not say where the error is?
Chrome reports a lot of parse errors as "Unexpected token … is not valid JSON" and gives no position. This tool works the location out from the quoted excerpt, so you still get a line and column.
Does it accept comments or trailing commas?
No, because JSON itself does not allow them. They are a common reason a file will not parse. JSONC and JSON5 are separate formats and need their own parsers.
Do big numbers survive a round trip?
Not always, and this is the quiet one. JSON has one number type and JavaScript reads it as a double, which holds integers exactly only up to about 9 quadrillion. A 64-bit database ID or a Twitter-style snowflake past that limit comes back off by one or two, silently, with no error anywhere. Anything that has to stay exact should be a string in the JSON, which is why so many APIs quote their IDs.
What happens if a key appears twice?
The last one wins and the earlier one disappears without a word. The specification permits it and every parser resolves it the same way, so a document with a duplicate key formats cleanly here and loses data on the way through. It is worth searching for when a value is mysteriously not what you set.
Why is the output ordering different from what I pasted?
It is not. Keys are left exactly where they were, because JSON objects are ordered as written and reordering them would change what a diff shows even when nothing meaningful changed. Some formatters sort alphabetically; that is a nicer-looking file and a worse code review.
How large a document can it handle?
A 5 MB file formats without freezing the page, because parsing runs on a background thread. Past that the limit is your device’s memory.