JSON Formatter & Validator
Guide: How to Fix the Most Common JSON Errors
Nothing you enter or choose here leaves your device. This tool runs in your browser.
What the formatter does with your JSON
Paste JSON into the box and the tool parses it right away. If it's valid, you can prettify it (add line breaks and indentation so a person can read it), minify it (strip every unneeded space for the smallest file) or sort the keys alphabetically. If it's invalid, you get the line, the column and a marker under the exact character where parsing failed.
The seven mistakes behind most errors
| Mistake | Broken | Fixed |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comment | {"a": 1 // note} | Remove the comment |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Undefined or NaN | {"a": undefined} | {"a": null} |
| Unescaped quote in a string | {"a": "say "hi""} | {"a": "say \"hi\""} |
The first four come from writing JSON as if it were JavaScript. JSON is stricter: keys and strings need double quotes, nothing may trail a final item, and there's no way to leave a comment. If your file has comments, it's probably JSONC or JSON5, a looser format that needs a different parser.
Reading the error message
The line and column point to where the parser gave up, which is often just after the real mistake. A missing comma on line 7 usually shows up as an error at the start of line 8, because that's the first place the parser sees something it didn't expect. If the marker looks fine, check the line above it.
When to prettify, minify or sort
- Prettify when you're reading an API response or checking a config file. Two spaces is the common choice, four if your team prefers it.
- Minify before sending JSON over a network or embedding it in a page. It removes whitespace only and doesn't change the data.
- Sort keys before comparing two files, so a reordered object doesn't look like a change. Array order is kept, because it carries meaning.
Things that look like bugs and aren't
- Big numbers change. JavaScript stores numbers as 64-bit floats, so an integer larger than 9,007,199,254,740,991 loses its last digits when parsed. IDs that long should travel as strings.
- Duplicate keys. The format allows them, but parsers keep only the last one, so earlier values disappear.
- Unicode escapes. A string written with a backslash-u code is the same data as the plain character, and it may print differently.
- Empty input isn't valid JSON. A single value such as
42or"hello"is.
Pasted data stays in your browser, so it's safe to check API responses that contain private details. Next steps from here: compare two versions in the JSON diff, build a description of the shape with the JSON schema generator, or pull out one value with the JSONPath tester. The guide to common JSON errors lists more.
Written by Akinrinmade Michael · Updated October 24, 2026
How to use
- 1Paste your JSON into the box. It is checked as you type.
- 2If it is invalid, read the message, line and column shown under the box.
- 3Pick an indent size, optionally sort keys, then click Prettify or Minify.
- 4Click Copy to copy the result.
Frequently asked questions
How do I find the error in my JSON?
The validator shows the line and column of the first problem, the text of that line and a marker under the exact spot. Common causes are trailing commas, single quotes and missing quotes around keys.
What is the difference between prettify and minify?
Prettify adds indentation and line breaks so humans can read it. Minify removes all unnecessary whitespace to make the smallest possible text.
Does sorting keys change my data?
It reorders object keys alphabetically, including nested objects. Array order is kept, and the values aren't changed.
Is my JSON sent to a server?
No. Parsing and formatting happen in your browser, so private data such as API responses stays on your device.
Read the guides
Learn how this works and how to get the most from it.
Developer
How to Fix the Most Common JSON Errors
Trailing commas, single quotes, unquoted keys and more. Learn to read a JSON error message and fix invalid JSON quickly.
4 min read
Developer
JSON vs YAML vs XML vs CSV: Choosing a Data Format
The strengths and weaknesses of JSON, YAML, XML and CSV, with simple advice on which to use for APIs, config files and spreadsheets.
3 min read
Related tools
JSON to DTO Generator
Turn JSON into Java, C#, TypeScript, Kotlin, Python or Go classes.
JSON Diff
Compare two JSON documents and see what changed, ignoring key order.
JSONPath Tester
Test JSONPath queries against your JSON and see every match.
YAML ⇄ JSON Converter
Convert YAML to JSON and JSON to YAML with error line numbers.