JSON formatter and validator
Paste JSON and this JSON formatter validates it, indents it neatly or minifies it, and points to the exact spot of any syntax error.
Last updated
Your text stays in your browser. Nothing you paste is uploaded or stored.
How to use the JSON formatter
- Paste your JSON into the input box.
- Press Format to indent it with two spaces, or Minify to remove all optional spacing.
- If the JSON is invalid, read the error message: it gives the line and column where the problem was found.
- Press Copy to put the result on your clipboard.
How the JSON formatter works
The formatter uses your browser's built-in JSON parser, the same one web applications rely on. If the parser accepts your text, the JSON is valid. The tool then writes it back out, either with two-space indentation and one value per line, or minified with no spaces at all.
Because the work happens locally, API responses, config files and keys you paste are never sent anywhere. That matters when the JSON contains customer records or credentials.
The logic
Format: output = JSON.stringify(JSON.parse(input), null, 2). Minify: output = JSON.stringify(JSON.parse(input)). If JSON.parse throws an error, the tool shows the message instead of an output, together with the line and column where parsing stopped.
Valid JSON needs double quotes around keys and strings, no trailing commas and no comments. Values can be objects, arrays, strings, numbers, true, false or null.
Example
The minified input {"name":"Ada","skills":["maths","code"],"active":true} formats into eight lines. Each of the three keys starts its own line, indented by two spaces, and the two items in the skills array get lines of their own, indented a further two spaces, before the closing bracket.
If you paste {"name":"Ada",} the parser stops at the closing brace, because a trailing comma is not allowed, and the tool reports the error at line 1, column 15.
Tips and common mistakes
Remove trailing commas and comments
JavaScript allows trailing commas and comments, but JSON does not. They are the most common cause of unexpected token errors.
Swap single quotes for double quotes
Keys and string values must use double quotes. 'name' is invalid; "name" is valid.
Watch out for very large numbers
JavaScript stores numbers as 64-bit floats, so whole numbers above 9,007,199,254,740,991 lose precision when parsed. Keep long IDs as strings.
Keep embedded images small
Images stored as Base64 strings make JSON files huge. Compress the image before you encode it.
Check long text fields
To see whether a description value fits a length limit, paste it into the word counter for an exact character count.
Frequently asked questions
Is my JSON sent to a server?
No. Parsing and formatting happen in your browser, so private data stays on your device.
Does the formatter fix invalid JSON?
No. It tells you where the first error is so you can fix it yourself. Automatic repairs can quietly change your data, so the fix stays in your hands.
Why did some numbers or keys change?
Numbers are rewritten in standard form, so 1.50 becomes 1.5 and 1e3 becomes 1000. Key order is kept, except that keys which look like whole numbers move to the front of their object.
What is the difference between Format and Minify?
Format adds line breaks and indentation so people can read the data. Minify removes every optional space to make the file as small as possible for sending over a network.
Can it handle large files?
Files of a few megabytes format almost instantly on most devices. Very large files, above roughly 50 MB, can make the page slow, especially on phones.