JSON formatter and validator

Paste JSON to beautify it, minify it, or find out exactly what is wrong with it. Syntax errors are reported with the line, the column and the offending line itself. Free, no signup, and the document never leaves your browser.

178 B
231 B
Output

Valid JSON

2 objects, 1 array, 8 keys, nested 3 levels deep.

Runs in your browser. The parser is JavaScript running in this tab. Your document is never uploaded, logged or stored, which matters because the JSON people paste into a formatter is usually a real API response with real data in it.

Why the error position is trustworthy

This page does not hand your document to the browser JSON.parse. It parses the text itself, character by character, keeping count of the line and column as it goes. That is deliberate: the built in parser words its errors differently in Chrome, Firefox and Safari, and some versions report only a character offset, which is useless when you are staring at a 400 line file.

Because the position is computed here, it is the same in every browser, and the offending line is printed underneath with a caret under the exact character. The message names the specific problem rather than saying the token was unexpected: a trailing comma, a single quoted string, an unquoted property name, a comment, a leading zero, or a tab that should have been escaped.

The mistakes that account for most invalid JSON

A trailing comma. Valid in JavaScript, valid in JSON5, not valid in JSON. It usually appears when the last item of a list was deleted by hand.

Single quotes. JSON strings and property names are always in double quotes. Text copied out of a Python session or a JavaScript console usually has the wrong ones.

Unquoted property names. A JavaScript object literal allows a bare key. JSON never does.

Comments. There is no comment syntax in JSON at all, which surprises people whose config files accept them.

Python literals. True, False and None are not JSON. The equivalents are lowercase true, false and null. NaN and Infinity have no JSON representation whatsoever.

Formatting only changes the whitespace

Most formatters parse your document into values and stringify them back, which quietly rewrites it. A long integer like 12345678901234567890 comes back as 12345678901234567000, because it does not fit in a JavaScript number. A huge exponent such as 1e400 becomes null. Duplicate keys collapse. Keys that look like integers get reordered, so an object keyed by 2 and 1 comes back the other way round.

This one keeps the original text of every number, the original order of every key and every duplicate that was there, and rewrites nothing but the spacing. Formatting a file and minifying it back gives you the same bytes you started with.

Frequently asked questions

Is my JSON sent to a server to be formatted?
No. The parser and the formatter both run in your browser, so the document stays on your device. That matters more here than on most tools, because the JSON people paste into a formatter is usually an API response with real customer data or a token in it.
How does it find the line and column of an error?
The page parses the JSON with its own parser rather than handing it to the browser. The built in JSON.parse reports errors differently in every engine, and some do not give a line and column at all. Parsing it here means the position is exact and identical in every browser.
Why does it say a trailing comma is invalid when my editor accepts it?
Because JSON itself does not allow one, even though JavaScript object literals, JSON5 and most editors do. The same goes for comments, single quoted strings and unquoted property names. If you need those, what you have is JSON5 or a JavaScript object, not JSON.
Does formatting change my data?
Only the whitespace. The formatter keeps the original text of every number, the original order of every key and any duplicate keys, because parsing into JavaScript values and back would rewrite them. A long integer would lose its last digits, a huge exponent would turn into null, and keys that look like integers would be reordered.
What indent size should I use?
Two spaces is the common default for JSON and keeps deeply nested documents readable on a narrow screen. Four suits configuration files that people read more than they scroll. Tabs let each reader choose their own width, which some teams prefer. Minified is for sending over the network, not for reading.
What does it mean when it warns about duplicate keys?
The same property name appears twice in one object. That is technically legal JSON, but almost every parser keeps only the last one, so it is nearly always a bug in whatever produced the document. The tool points at the object it found them in rather than silently dropping one.

Debugging is easier than revising. FORKSAI helps with the other one.

Turn your notes, slides and PDFs into flashcards and spaced repetition sessions, and stop rereading the same page hoping it sticks.

The tool above stays free and needs no account.

More free tools

There are file and format tools too, such as image converter, compress image to size, favicon generator, and the full set is on the free tools hub.

Plan your next review session

Use the free student study kit to plan a week of revision, check flashcard quality, and record mistakes from practice questions.

Need a deck first? Turn a lecture PDF into editable flashcards, then follow the active recall guide to practise answering before revealing the back of each card.

Working toward an exam? Build a daily target with the exam study planner, protect the session with the Pomodoro study timer, or check your current result with the weighted GPA calculator.