How to format and validate JSON
- Paste your JSON into Input, or click Open file to load a .json file from your device. A sample is already loaded so you can see the result straight away.
- The output updates as you type. Format & Validate gives indented output and Minify gives one compact line.
- Pick an Indent of 2 spaces, 4 spaces or a tab. Tick Sort keys A to Z to alphabetize the keys of every object.
- If the status box says the JSON is invalid, it gives the line and column and shows the offending line. Press Jump to error, or try Fix common errors to remove trailing commas and comments and to turn single quotes into double quotes.
- Use Copy or Download .json to take the result with you.
How it works
The tool reads your text with a strict parser that follows the JSON grammar in RFC 8259 (the same grammar as ECMA-404), then writes it back out token by token and changes only the whitespace. Many formatters call JSON.parse and then JSON.stringify, which rewrites numbers because JavaScript stores them as 64-bit floating point values. An ID like 12345678901234567890 turns into 12345678901234567000, and 1.10 turns into 1.1. Here every number and string is copied exactly as you typed it.
Worked example
The default input is a one-line record. With Format & Validate and an indent of 2 spaces it becomes 16 lines, and the status box reads "Valid JSON. 16 lines, 230 bytes, 2 levels deep."
{
"id": 12345678901234567890,
"name": "Ada Lovelace",
"active": true,
"balance": 1.10,
"tags": [
"math",
"code"
],
"address": {
"city": "London",
"visit": "10:30",
"zip": null
},
"notes": []
}
Notice that id keeps all 20 digits, balance keeps its trailing zero, and the colon inside "10:30" is left alone. The status box also warns that the ID is too large for a JavaScript number, so any code that reads it with JSON.parse would round it.
Limits and edge cases
- Comments, trailing commas, single quotes and unquoted keys are not valid JSON. They are reported as errors, and Fix common errors can repair them.
- Duplicate keys in one object are allowed by most parsers, which keep the last one. This tool keeps both and warns you.
- A non-breaking space pasted from a web page is not JSON whitespace. The error names its code point, U+00A0, so you can find it.
- Nesting deeper than 1,500 levels and files over 25 MB are refused. Outputs over about 20,000 lines are shown in plain text without colors to keep the page responsive.
- JSON Lines files (one JSON value per line) are not one JSON document. Check them one line at a time.
Frequently asked questions
Why does my JSON say it is invalid?
The usual causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, and comments. The status box gives the line and column of the first problem, so fix that one and the tool re-checks as you type.
Does the formatter change my numbers or key order?
No. Numbers, strings and the order of keys are kept exactly as you typed them, and only whitespace changes. The one exception is the Sort keys A to Z option, which reorders keys on purpose.
What does minifying JSON do?
Minify removes every space and line break that is not inside a string, so the data stays identical but takes fewer bytes to store or send. Format & Validate does the reverse and adds indentation for reading.
Can JSON contain comments?
No. RFC 8259 has no comment syntax, so a standard parser rejects them. Formats such as JSONC and JSON5 allow comments, and Fix common errors strips them so you get plain JSON.
Next steps: turn the result into types with the JSON to TypeScript converter, convert it with the YAML to JSON converter or the CSV to JSON converter, or compare two versions with the diff checker. For style advice, read JSON formatting best practices.