How to use the json formatter and validator
- Paste your JSON into the box. The result updates as you type.
- Choose a layout: two spaces, four spaces, tabs or minified.
- Tick the box to sort object keys A to Z if you want a stable order.
- If the JSON is not valid, read the message and the pointer under the line. Fix the problem and the result appears. Then copy the result.
How the checking works
Your text is checked with the browser's own JSON.parse, which never runs your text as code. A small strict parser then reads the text in the same way, and it is used to find where the problem is, so that the line and column are the same in every browser. Safari, for example, does not give a position in its own message.
When something is wrong, the message names the line, column and character position and says what it expected, such as a double-quoted property name. Under the message the tool shows the line with a caret under the spot. The usual problems are a trailing comma, single quotes, a missing comma between items, an unquoted key or a comment.
What formatting keeps and changes
Numbers and strings are written back exactly as you typed them, so 1.50 stays 1.50, 1E5 stays 1E5 and a 20 digit number keeps every digit. Many formatters that parse and re-write the data lose those details. Key order is kept unless you sort, and duplicate keys are kept as they are, which the status line points out.
Sorting uses plain code unit order, so uppercase letters sort before lowercase ones. Only object keys are sorted. Arrays keep their order, because the order of items usually matters. Minified output removes every space that is not inside a string.
Limits and privacy
Everything runs in your browser and nothing is uploaded. The tool handles up to 2,000,000 characters and up to 1,000 levels of nesting, and it says so if you go past those limits. A byte order mark at the start of the text is reported as an error because JSON does not allow it.
To explore a large document as a tree, use the JSON viewer. To convert tables to and from JSON, try the CSV and JSON converter, and to compare two versions, the diff checker. The Base64 encoder and decoder helps with encoded payloads.
Assumptions and limits
- Validity is decided by the browser's JSON.parse, and the text is never run as code.
- The grammar is standard JSON: double-quoted strings, no comments, no trailing commas and no single quotes.
- Formatting keeps number and string text exactly as written. Sorting is by UTF-16 code unit order.
- Text up to 2,000,000 characters and 1,000 levels of nesting is supported.
Frequently asked questions
How do I find the error in my JSON?
Paste it in and read the message. It gives the line, column and character position, and shows the line with a caret under the spot. The most common causes are a trailing comma, single quotes and a missing comma.
Does the formatter change my numbers?
No. Numbers and strings are written back exactly as typed, so 1.50 stays 1.50 and long numbers keep all their digits.
Is my JSON sent anywhere?
No. It is checked and formatted in your browser and never uploaded.
Why is a comment or a trailing comma an error?
The JSON standard does not allow either. Some tools accept them as an extension, but the standard parser rejects them, so the tool reports them.