How to format or validate JSON
- Paste your JSON into the input box.
- Click Format to pretty-print it with indentation, or Minify to remove all unnecessary whitespace.
- If the JSON is invalid, you'll see a message with the line and column of the first problem, and the cursor jumps there so you can fix it.
- Copy or download the result. Edit result moves it back into the input box for further changes.
The most common JSON errors
| Error | Wrong | Right |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | Not allowed in JSON |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Special values | NaN, undefined | null |
JSON is stricter than JavaScript object syntax. Many of these are allowed in JavaScript, JSON5 or YAML, which is why copy-pasted snippets often fail validation.
Things to know
- Big numbers: JSON itself allows any size of number, but JavaScript (and therefore this tool) stores numbers as 64-bit floating point. Integers larger than 9,007,199,254,740,991 — such as some database IDs — lose precision when formatted. The tool warns you when your input contains such numbers; keep those IDs as strings if you can.
- Duplicate keys are allowed by the parser; only the last value is kept in the output.
- Sort keys orders object properties alphabetically at every level, which makes two JSON documents much easier to compare. Array order is never changed.
- Minified JSON is the same data with whitespace removed — smaller for sending over a network, but hard to read.
Frequently asked questions
Is my JSON sent to a server?
No. Parsing and formatting happen in your browser with JavaScript’s built-in JSON parser. That makes it safe to paste API responses that contain access tokens, emails or customer data.
Why does it say my JSON is invalid when it works in my code?
JavaScript and many config formats accept things that strict JSON doesn’t: single quotes, unquoted keys, trailing commas and comments. The error message points to the exact line and column so you can fix it.
What is the difference between formatting and minifying?
Formatting (beautifying) adds line breaks and indentation so humans can read the structure. Minifying removes all whitespace that isn’t inside strings, producing the smallest equivalent text.
Can it handle large files?
Yes, files of several megabytes format in well under a second on a typical computer. Extremely large files (hundreds of megabytes) may exceed browser memory.