TheTools.World tool
JSON formatter and validator online
Paste JSON to validate it and format it with readable indentation, or minify it into a single compact line. Invalid JSON shows a clear error message so you can find and fix the problem.
Format or validate JSON
Paste JSON to validate it and format it with readable indentation, or minify it into a single compact line. Invalid JSON shows a clear error message so you can find and fix the problem.
How to format or validate JSON
- Paste your JSON into the box.
- Choose an indent size, or check Minify to compress it to one line instead.
- Click Format JSON.
- If the JSON is valid, review the formatted result and check the summary (type and top-level key/item count).
- If the JSON is invalid, read the error message, which usually points to the approximate position of the problem.
This tool validates strict JSON syntax. JavaScript object literals with unquoted keys, trailing commas, or single-quoted strings are not valid JSON and will be reported as errors.
What this does and how it works
This tool parses your input using the browser's built-in JSON.parse, which enforces strict JSON syntax: double-quoted keys and strings, no trailing commas, and no comments. If parsing succeeds, the result is re-serialized with JSON.stringify using your chosen indentation (or compacted to one line if Minify is checked). If parsing fails, the browser's own error message is shown, which typically includes the character position or line/column where the problem was found.
Best practices
- Validate before you format. If the JSON is invalid, formatting can't happen until the syntax error is fixed — use the error message's position hint to find the issue.
- Use 2-space indent for most code review and documentation, and minify only when you need a compact single-line value (like for an environment variable or a URL parameter).
- Check the top-level type and count in the summary to sanity-check that you parsed what you expected (an array vs. an object, or the right number of keys).
Common mistakes to avoid
- Pasting a JavaScript object literal instead of JSON. Unquoted keys, single quotes, trailing commas, and comments are all valid in JavaScript but invalid in strict JSON, and will be rejected here.
- Missing a closing brace or bracket after editing JSON by hand, which is one of the most common causes of a parse error.
- Assuming minified JSON is functionally different from formatted JSON. Whitespace doesn't change the data; minifying only changes how it looks, not what it means.
Real-world use cases
- Reading an API response that came back as a single unreadable line.
- Validating a config file or payload before using it, to catch syntax errors early.
- Minifying JSON before pasting it into a place with limited space, like a URL query parameter or an environment variable.
- Debugging a "invalid JSON" error from other software by pinpointing exactly where the syntax breaks.
Limitations
This tool checks JSON syntax validity only; it does not check the data against a schema, so syntactically valid JSON with the wrong structure for your specific use case will still pass. It also does not preserve key order guarantees beyond what JavaScript's JSON.parse/stringify already provide, and does not support JSON5 or JSONC extensions like comments or trailing commas.
Privacy
JSON you paste is processed locally in your browser using the browser's built-in JSON parser. It is not sent to a server, logged, or stored. See the privacy policy for the site's full data handling approach.
Troubleshooting
- If you get a syntax error, check the character position mentioned in the message and look for a missing comma, quote, brace, or bracket near that point.
- If your data has unquoted keys or trailing commas, it's a JavaScript object literal, not JSON — add quotes around keys and remove trailing commas.
- If your data includes comments, remove them; standard JSON does not support comments.
Conclusion
Use this tool to validate, pretty-print, or minify JSON quickly, with a clear error message when something's wrong. For formatting HTML or XML instead, see the HTML formatter or XML formatter.
Related tools
FAQ
Why does my JavaScript object fail to validate?
Strict JSON requires double-quoted keys and strings, no trailing commas, and no comments. JavaScript object literals allow all of these, so a valid JS object may not be valid JSON.
What does the error message tell me?
It's the browser's own JSON parser error, which usually includes the character position or line/column of the first syntax problem found.
Does minifying change the data?
No. Minifying only removes whitespace and line breaks; the underlying data structure and values are unchanged.
Is my JSON uploaded anywhere?
No. Parsing and formatting happen locally in your browser using its built-in JSON parser, and your data is not sent to a server.