JSON Formatter & Validator
Paste JSON to beautify, minify or validate it; if something is wrong you get the approximate line and column. Data is processed only in your browser and never sent to a server.
Note: validation follows strict JSON, so comments, trailing commas and single-quoted strings are reported as errors.
How to use
- Paste JSON into the input box on the left — an API response, a config file, a snippet from a log, or data squashed onto a single line.
- Click "Format" to pretty-print it with 2 spaces, 4 spaces or tabs; "Minify" to strip all whitespace into one line; or "Validate only" if you just want to know whether it's correct.
- Tick "Sort keys" to order every object's keys alphabetically, which makes two payloads much easier to compare.
- The result appears on the right, ready to copy or download as formatted.json. Valid input shows its size, number of keys and maximum nesting depth; invalid input shows the approximate line and column of the problem.
When it's useful
Expanding a long API response to understand its structure while debugging. Checking the syntax of package.json, tsconfig.json or editor settings before and after you edit them. Minifying pretty JSON into one line for an environment variable, a request body or a database field. Sorting keys before comparing two responses to see what changed. Tidying sample data for documentation or test fixtures.
Tips
- The error position is where the parser noticed a problem. The real mistake is often just before it — a missing comma or quote at the end of the previous line, for example.
- The usual suspects: unquoted keys, single quotes, a trailing comma after the last item, // comments, and JavaScript values like undefined or NaN, none of which are valid JSON.
- JSON copied from web pages, documents or chat apps sometimes contains curly "smart" quotes. Replace them with straight double quotes.
- Sorting keys only affects objects. Array items keep their order, so the meaning of the data doesn't change.
Format, minify or validate?
Formatting is for humans: indentation shows how objects and arrays nest, so you can spot a missing field or a wrongly nested value at a glance. Minifying is for machines: it removes every unnecessary space and line break, which keeps payloads, logs and environment variables compact. Two-space indentation is the most common convention in JavaScript projects, four spaces is popular in Python, and tabs let each reader choose their own width. "Validate only" is handy when you just want a quick yes or no without changing the text you already have.
Privacy
Formatting and validation use your browser's built-in JSON parser, entirely on your device. Whatever you paste is never sent to a server and isn't saved. API responses containing tokens or user data are safe to work with here — though it's still wise to remove sensitive fields before sharing the result with anyone.
FAQ
Q: Is my data uploaded?
A: No. Everything is processed in your browser; the page never sends your input anywhere.
Q: Does it support JSON with comments (JSONC / JSON5)?
A: No. It validates strict JSON, so comments, trailing commas and single quotes are reported as errors. Remove the comments first, then format.
Q: Can it handle large files?
A: A few megabytes usually take a second or two. At tens of megabytes the browser may struggle; a command-line tool such as jq is better suited.
Q: Can big numbers change?
A: Yes, that's a risk. Integers larger than 2^53 (some 18-digit IDs, for example) lose precision in JavaScript, so their last digits may change after formatting. Ideally such values should be strings at the source.
Q: Why is the reported error position a bit off?
A: Browsers word their errors differently and some only give a character offset, which this tool converts to a line and column. The position marks where the parser noticed the problem, so check the text just before it too.
Q: Will non-English text be turned into \u escapes?
A: No. Accented letters, CJK characters and emoji are kept as they are.