How to use the JSON Formatter & Validator
- Paste your JSON into the box: an API response, a config file or a log line.
- Choose pretty-printed output with 2 spaces, 4 spaces or tabs, or minified output with all whitespace removed.
- Tick Sort keys A–Z to order every object's keys alphabetically, which makes two JSON files easier to compare.
- If the JSON is invalid, read the error message for the line and column of the problem.
- The result updates instantly as you type. There is no button to press.
- Use Copy result to copy the figures, or Copy link to share a link that reopens the JSON Formatter & Validator with the same inputs.
How it works
JSON (JavaScript Object Notation) is the most common format for exchanging data between web services, apps and configuration files. Machines send it minified, on a single line with no spaces, which is efficient but almost impossible for a person to read. This tool parses your JSON and re-prints it with consistent indentation, one value per line, so the structure is obvious.
Because the tool fully parses the input before formatting it, it doubles as a validator. If the JSON is invalid, it tells you where parsing failed, by line and column, and why. The most common mistakes are trailing commas after the last item, single quotes instead of double quotes, unquoted keys, comments (which standard JSON doesn't allow), and missing commas between items. These are all valid in JavaScript but not in strict JSON.
Minify does the reverse of pretty-printing, stripping all optional whitespace to make payloads smaller. Sort keys reorders the keys of every object alphabetically, at every level, without changing array order, which is handy for comparing two responses with the text compare tool. Your JSON is processed only in your browser, so it is safe to paste data containing tokens or personal information.
Formula
Formatting is JSON.parse followed by JSON.stringify with the chosen indent. Numbers are kept as JavaScript doubles, so integers above 2⁵³ (9,007,199,254,740,992) can lose precision.
Example
The minified input {"name":"FigureNook","tools":60,"tags":["free","fast"]} becomes an 8-line document with two-space indentation, each key on its own line and the array items indented beneath "tags". If you accidentally write {"tools": 60,}, the validator reports an error at the closing brace, pointing straight at the trailing comma.
Frequently asked questions
Why is my JSON invalid when it works in JavaScript?
JavaScript object literals allow single quotes, unquoted keys, trailing commas and comments. Strict JSON allows none of these. Use double quotes everywhere and remove trailing commas and comments.
Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser, and the JSON isn't added to the share link.
Can it handle very large numbers?
JSON allows any size of number, but browsers read them as 64-bit floating point, so integers above 9,007,199,254,740,992 may be rounded. Store very large IDs as strings to be safe.