Home JSON formatter
JSON formatter and validator
Paste JSON to pretty-print it, minify it or find out exactly why it does not parse. It runs in this tab, and it changes whitespace — never your numbers, your key order or a duplicate key it found.
Other languages:TürkçeDeutsch中文हिन्दीРусский
A formatter that does not rewrite your data
Most online formatters run your text through JSON.parse and print the result.
That is not formatting, it is a round trip through JavaScript, and it changes things a
formatter has no business changing:
| Input | After JSON.parse + stringify | Here |
|---|---|---|
{"id": 12345678901234567890} | 12345678901234567000 | 12345678901234567890 |
{"price": 19.90} | 19.9 | 19.90 |
{"n": 1E+5} | 100000 | 1E+5 |
{"b": 1, "2": 2} | {"2": 2, "b": 1} | {"b": 1, "2": 2} |
{"a": 1, "a": 2} | {"a": 2}, silently | both kept, and a warning |
The first row is the one that costs people a day: JavaScript numbers are 64-bit floats, so any
integer above 253 — a Twitter/X post ID, a Discord ID, a database
BIGINT — is rounded the moment it is parsed. This formatter reads the document
with its own parser and writes every number back exactly as it was written. Keys keep their
order (JavaScript objects move integer-like keys to the front), and a duplicate key is kept
and reported instead of quietly losing one of its values.
The one thing that is normalised is the spelling of string escapes: "\u00e9" is
written as "é" and "\/" as "/". The value is the
same character either way.
Errors that say what to do
A browser's own message for invalid JSON is usually “Unexpected token” and a character offset. The validator here names the line and column, shows the line with a caret under the problem, and says which of the usual mistakes it is. Go to error puts the cursor on it.
| Input | What it reports |
|---|---|
{"a": 1,} | Trailing comma before } — JSON does not allow one. |
{'a': 1} | Property names must use double quotes — single quotes are not JSON. |
{a: 1} | Property names must be in double quotes. |
{"a": 1 "b": 2} | Missing comma between two properties. |
{"a": 007} | Numbers cannot have leading zeros — write it as a string if the zeros matter. |
{"a": NaN} | NaN is not a JSON value — use null or a string. |
{"a": True} | True is Python — JSON writes true in lower case. |
// comment | Comments are not allowed in JSON. |
{"a":1}{"b":2} | A second value starts here — wrap several in [ ], or use NDJSON. |
The rules are RFC 8259's, strictly: no comments, no trailing commas, no single quotes, no
NaN or Infinity. JSON5 and JSONC files (VS Code settings,
tsconfig.json) allow some of those and will be reported as invalid here, which
is correct for anything that has to be read by a strict JSON parser.
Options
- Indent — 2 spaces, 4 spaces, tabs, or minified onto one line with no spaces at all.
- Sort keys A–Z — recursively, by character code. Useful before diffing two responses whose key order differs; leave it off when order carries meaning.
- Open file or drop a file onto the input — up to 2 MB, read locally.
The summary line counts objects, arrays and values and reports the nesting depth, which is a quick way to see that a response has the shape you expected before reading it.
Common questions
Is my JSON uploaded anywhere?
No. Parsing and formatting happen in JavaScript in your own tab, so the document never leaves your machine. That makes it safe for API responses and config files you would not paste into a hosted tool.
Why does this keep my big numbers when other formatters change them?
Other formatters parse with JSON.parse, which stores every number as a 64-bit float and rounds integers above 2^53. This one parses with its own reader and writes each number back exactly as it was written, so 12345678901234567890 stays 12345678901234567890 and 19.90 stays 19.90.
Does it accept comments or trailing commas?
No — those are JSON5 and JSONC extensions, not JSON. They are reported as errors with their line and column, which is what a strict parser in production would do with them.
What happens to duplicate keys?
Both are kept in the formatted output and the validator warns about the second one. JSON.parse would silently keep only the last value, which is how a duplicate key in a config file goes unnoticed.
Can it minify JSON?
Yes. Choose Minified in the indent menu and the output is a single line with no insignificant whitespace — the smallest valid encoding of the same document.
Related
- /json-to-yaml-converter — the same document as YAML, with the strings YAML would retype quoted.
- /json-to-typescript — a TypeScript interface for the JSON you just validated.
- /json-to-csv-converter — flattening an array of objects into a spreadsheet.
- /json — generating typed JSON test data from scratch.
Last updated