TTKTheTextKit

JSON Formatter & Validator

Paste raw or minified JSON to validate it and pretty-print it with 2 or 4 spaces of indentation. Switch to minify to compact it onto one line. If the JSON is not valid, the tool names the first problem in plain words with its line and column, for example a trailing comma, a single-quoted string or a missing comma. Only the white space changes: numbers, strings and the order of keys stay exactly as you wrote them. Everything runs locally in your browser.

Related Tools

[7 suggestions]

Guides for the JSON Formatter

About the JSON Formatter & Validator

The JSON Formatter checks your text against the JSON grammar (RFC 8259) and re-indents it by changing only the white space between tokens. A common shortcut is JSON.parse() followed by JSON.stringify(), but that rewrites the data: a number such as 12345678901234567890 becomes 12345678901234567000, 1.50 becomes 1.5, keys that look like integers move to the front, and when a key appears twice only the last value survives. This tool leaves all of that alone, and it warns you about repeated keys and about numbers a JavaScript program would round. Its validator accepts exactly the text that JSON.parse() accepts (we compared them on 40,000 damaged documents), but the message does not depend on your browser: it explains what is wrong, such as a trailing comma, single quotes, an unquoted key, a comment, NaN, a leading zero or a line break inside a string, and gives the line and column. Minify mode removes every unnecessary space and line break, which is useful before embedding JSON in an API request or an environment variable.

Why does my JSON fail to parse?▾

JSON has strict rules: property names and strings need double quotes, a comma cannot follow the last item, and comments, NaN and undefined are not allowed. The tool shows the first problem with its line and column and says how to fix it.

What is the difference between pretty-print and minify?▾

Pretty-print adds line breaks and 2 or 4 spaces of indentation so the structure is easy to read. Minify removes all unnecessary white space to produce the smallest valid text, which is useful for API requests and storage. Neither changes the data.

Does this support JSON with comments (JSONC)?▾

No. Standard JSON does not allow comments, and the tool will point at the first comment it finds. If you have JSONC, as in tsconfig.json, remove the comments before pasting.

Does formatting change my numbers or key order?▾

No. Many formatters parse the JSON and write it back, which rounds large numbers and reorders keys that look like integers. This tool only changes white space, so 12345678901234567890 and 1.50 stay as written.

What happens if a key appears twice?▾

The text is valid JSON, and the tool keeps both keys and shows a warning. Most programs keep only the last value, so the first one is silently lost when the data is read.