What the formatter does
JSON (JavaScript Object Notation) is plain text with a strict grammar, defined in RFC 8259. The tool reads your text one character at a time and checks it against that grammar. If everything is valid, it rebuilds the data with the layout you choose: indented with 2 spaces, 4 spaces or tabs, or minified onto a single line. If something is wrong, it stops at the first error and tells you the exact line and column, what it expected, and how to fix it.
Valid JSON has only six kinds of value:
| Value | Example | Rules |
|---|---|---|
| Object | {"name": "Ann"} |
Keys must be strings in double quotes |
| Array | [1, 2, 3] |
Items separated by commas, no comma after the last |
| String | "hello" |
Double quotes only; escape ", \ and line breaks |
| Number | -12.5e3 |
No leading zeros, no +, no hex, no NaN |
| Boolean | true |
Lowercase only |
| Null | null |
Lowercase only |
Why your numbers stay exactly as written
Most online formatters call the browser’s JSON.parse and then JSON.stringify. That round trip quietly changes data. JavaScript stores every number as a 64-bit float, which holds whole numbers exactly only up to:
So an ID such as 12345678901234567890 comes back as 12345678901234567000, and 1.50 becomes 1.5. This formatter never converts numbers. It copies each number and each string exactly as you typed it, escapes included, and only changes the whitespace between them. When it finds an integer beyond the safe limit it still keeps it, but shows a warning, because other programs reading the file with JSON.parse will round it.
Worked example: fixing a broken config
Paste this:
{
"name": "shop",
"port": 8080,
"debug": true,
}
The validator reports Line 4, column 16: Trailing comma before }, with a caret under the comma after true. Delete that comma and the status turns to “Valid JSON · object with 3 keys”. Click Minify and you get {"name":"shop","port":8080,"debug":true}: 40 characters instead of 53, about 25% smaller.
Now change "port": 8080 to port: 8080. The error becomes Property names must be in double quotes, and the hint suggests writing "port":. Click Go to error to jump straight to the spot in the input box.
The most common JSON errors
- Trailing commas. JavaScript allows
[1, 2, 3,]; JSON does not. - Single quotes.
'text'is not valid; use"text". - Unquoted keys.
{name: "Ann"}must be{"name": "Ann"}. - Comments. Standard JSON has no
//or/* */comments. - Curly quotes. Copying from Word, Google Docs or a chat app can turn
"into “ or ”. They look similar but are different characters. - Missing commas between two properties, usually after adding a new line.
- Python values.
True,FalseandNonemust betrue,falseandnull. - Two documents in one.
{"a":1} {"b":2}is two values. Wrap them in an array, or treat the file as JSON Lines and check one line at a time.
If the first character is <, you probably pasted an HTML page, often an error page returned by an API instead of the data you expected.
Comments and trailing commas
Some files look like JSON but allow extras, for example tsconfig.json and VS Code settings (“JSONC”). Tick Allow comments and trailing commas to read them. The tool then skips // and /* */ comments and ignores a comma before } or ]. The output is always standard JSON, so the comments are removed. Single quotes, unquoted keys, NaN, Infinity and hex numbers still count as errors, because no common JSON-like format agrees on them.
Sorting keys and the tree view
Sort keys A→Z puts the properties of every object, at every level, in alphabetical order (by character code, so capital letters come before lowercase ones). Sorting makes two versions of the same data easy to compare: format both with sorted keys, then paste them into Text Compare to see only the real differences.
The Tree view shows the structure as collapsible branches. Each object shows how many keys it has and each array how many items, so you can find your way through a large API response without scrolling through thousands of lines. Big arrays load 100 items at a time.
Duplicate keys
{"id": 1, "id": 2} is technically allowed by the grammar, but most parsers keep only the last value, so the first one is silently lost. The validator accepts it and flags each repeat as a warning with its line and column.
For the full syntax rules and fixes for the error messages people hit most, see our guide on how to format JSON.
Large files and privacy
Everything runs in your browser, inside a background worker. Inputs larger than 1 MB are checked about a second after you stop typing, so the page stays responsive even with files of tens of megabytes. Nothing is uploaded, which matters because JSON often contains API keys, tokens and customer data.
Need to go further? Encode the result with the Base64 encoder, or create a checksum of it with the hash generator to confirm a copy matches the original.