JSON Formatter & Validator
Clean, minify, and debug JSON payloads with synchronized line numbers and client-side tree navigation.
Strict Syntax Pinpointing
Synchronized line counters immediately locate missing quotes, trailing commas, and bad brackets.
Instant File & Drag-and-Drop
Open multi-megabyte log files or configuration documents directly without copying to your clipboard.
Private Browser Execution
Zero server telemetry. Sensitive API tokens, mock database tables, and user records stay entirely in local memory.
The eight JSON mistakes that cause most errors
JSON looks like the objects you write in code, but it is a stricter text format (defined in RFC 8259). Almost every "invalid JSON" message comes from one of these. The third column is what this validator reports for the example, so you can match it to what you see.
{"name": "Sam", "age": 30,}You will see: A trailing comma before '}' isn't allowed in JSON
Fix: Delete the last comma. It is the one just before the closing } or ].
{'name': 'Sam'}You will see: Property names must use double quotes, not single quotes
Fix: Swap every ' for ". JSON allows double quotes only.
{name: "Sam"}You will see: Expected a double-quoted property name but found 'n'
Fix: Put the key in double quotes, like "name": "Sam".
{"name": "Sam" // the user}You will see: Comments aren't allowed in JSON
Fix: Remove the comment, or keep the note in a separate field.
{"name": "Sam" "age": 30}You will see: Expected ',' or '}' after this property, but found '"'
Fix: Add a comma between the two items.
{"score": undefined}You will see: 'undefined' is not valid in JSON (use null)
Fix: Use null for a missing value. NaN and Infinity are not valid either.
{"zip": 02134}You will see: Invalid number: numbers cannot have leading zeros
Fix: If it is an identifier such as a postcode, make it a string: "02134".
{"items": [1, 2, 3}You will see: Expected ',' or ']' after this array item, but found '}'
Fix: Close the [ with a ] before closing the { with a }.
| Mistake | Example that fails | Message you will see | How to fix it |
|---|---|---|---|
| Trailing comma | {"name": "Sam", "age": 30,} | A trailing comma before '}' isn't allowed in JSON | Delete the last comma. It is the one just before the closing } or ]. |
| Single quotes | {'name': 'Sam'} | Property names must use double quotes, not single quotes | Swap every ' for ". JSON allows double quotes only. |
| Unquoted key | {name: "Sam"} | Expected a double-quoted property name but found 'n' | Put the key in double quotes, like "name": "Sam". |
| Comment | {"name": "Sam" // the user} | Comments aren't allowed in JSON | Remove the comment, or keep the note in a separate field. |
| Missing comma | {"name": "Sam" "age": 30} | Expected ',' or '}' after this property, but found '"' | Add a comma between the two items. |
| undefined or NaN | {"score": undefined} | 'undefined' is not valid in JSON (use null) | Use null for a missing value. NaN and Infinity are not valid either. |
| Leading zero | {"zip": 02134} | Invalid number: numbers cannot have leading zeros | If it is an identifier such as a postcode, make it a string: "02134". |
| Mismatched bracket | {"items": [1, 2, 3} | Expected ',' or ']' after this array item, but found '}' | Close the [ with a ] before closing the { with a }. |
Every message also shows a line and column, and the line numbers in the editor match them.
What counts as valid JSON
A JSON document is one value, and a value is one of six things:
- string: text in double quotes, such as
"Perth" - number:
42,-3.5or1e3, with no leading zeros and no quotes - true or false, in lowercase
- null, in lowercase, for "nothing here"
- object: pairs of
"key": valueinside curly braces, separated by commas - array: an ordered list of values inside square brackets, separated by commas
Objects and arrays can nest inside each other as deep as you like, which is why the tree viewer is handy for reading a large file. Spaces, tabs and line breaks between values are ignored, so formatting changes how it looks and not what it means.
Format or minify? A worked example
Here is the same small record laid out two ways. They hold exactly the same data.
{
"id": 1042,
"name": "Sam Rivera",
"active": true,
"tags": ["admin", "beta"],
"address": {
"city": "Perth",
"postcode": "6000"
}
}{"id":1042,"name":"Sam Rivera","active":true,"tags":["admin","beta"],"address":{"city":"Perth","postcode":"6000"}}Minifying removed 37 characters, about a quarter, just by taking out spaces and line breaks. On a large payload that adds up, which is why web services often send the minified form. Use Format when a person needs to read or edit it, such as debugging an API response or checking a config file, and Minify when it is going over a network or into a small field. The 2-space and 4-space buttons only change how far the indents go.
Why this formatter keeps your numbers and keys exactly as typed
Many online formatters run your text through the browser's built-in parser and then write it back out. That round trip can quietly change the data:
- A long number such as
12345678901234567890comes back as12345678901234567000, because browsers store numbers as 64-bit floating point. Long IDs, such as database or payment identifiers, are the usual victims. - Repeated keys are dropped, so
{"a":1,"a":2}becomes{"a":2}with no warning. - Values like
1.0and0.10lose their trailing zeros.
This tool reads your text itself, keeps every number and string as written, keeps keys in your order, and warns you when a key repeats. Only the whitespace changes. If you are checking an API response or a saved file, what you read here is what is in the file.
Related: compare two JSON files with the diff checker, encode a value with the Base64 and URL encoder, turn a timestamp into a date with the epoch converter, or generate IDs with the UUID generator.
Frequently Asked Questions
Is my JSON data secure and private?โผ
Yes. All validation, parsing, formatting, and tree-building execute strictly in your browser memory. Nothing is sent to an external server or logged.
Can I upload large JSON files?โผ
Yes. You can drop any .json, .txt, or .log file directly into the editor or click 'Upload File'. The browser parses it directly via local memory without uploading to a server.
How does the validator pinpoint syntax errors?โผ
The built-in parser inspects error tokens, trailing commas, unmatched brackets, and character offsets to identify the exact line number and column where syntax broke.
Why does my JSON fail when it works in my code?โผ
Code editors and JavaScript itself accept things that real JSON does not: single quotes, unquoted keys, comments, trailing commas and values such as undefined or NaN. JSON is stricter, which is why a file that runs fine in a script can be rejected by a validator, an API or a config loader. The table on this page lists the usual culprits and the fix for each.
Can JSON contain comments?โผ
No. The JSON standard (RFC 8259) has no comment syntax, so // and /* */ are errors. If you need notes, either keep them in a separate file, or add a field that is just for notes, such as a key called "_comment". Some tools read a relaxed dialect called JSONC or JSON5 that allows comments, but a strict validator will reject it.
What is the difference between JSON and a JavaScript object?โผ
JSON is a text format based on JavaScript object syntax, but it is much stricter. Keys must be in double quotes, strings must use double quotes, and there are no functions, comments, trailing commas or undefined values. A JavaScript object lives in memory, and JSON is the text you send or save.
Does formatting change my data?โผ
No. This tool only changes the whitespace between values. Numbers and strings are kept exactly as you typed them, and keys stay in the order you wrote them. That differs from many online formatters that rewrite the JSON through the browser's own parser, which can quietly round long numbers and drop repeated keys. See the section on exact numbers below.