JSON formatter / validator

Beautify messy JSON, minify it back to one line, or catch the syntax error — all parsed on your device with JSON.parse.

Paste any JSON into the box and press Format / Beautify to get it back with tidy two-space indentation, one key per line and consistent spacing — the shape that makes a config file or an API response actually readable. Press Minify instead to strip every unnecessary space and newline so the same data collapses to a single compact line. Either way the tool first runs your text through JSON.parse, so if the JSON is broken you get a precise error instead of a silent mess. Nothing is uploaded; every step happens in your browser.

Try:
0Words
0Characters
0No spaces
0Sentences
0Paragraphs
0Lines
0Pages
0Reading
0Speaking

Runs entirely in your browser. Your text is never uploaded — open DevTools, Network tab, and you will see zero requests while you use this tool.

How to use it

  1. Paste your JSON — an API response, a config file, a log line, whatever you have — into the input box.
  2. Press Format / Beautify to expand it into indented, human-readable form, or Minify to compress it to one line.
  3. If the JSON has a syntax error the tool tells you where it failed instead of formatting. Fix the spot it points to and try again.
  4. Press Copy to grab the result, or Download .txt to save it.

What this tool does

The tool does two jobs on top of one guarantee. The guarantee is that it parses your input with the browser's native JSON.parse before it does anything else. That means the output is never just your text with spaces shuffled around — it is a fresh serialisation of the real data structure your JSON describes. If JSON.parse refuses your input, you have invalid JSON, and the tool says so rather than pretending.

Beautify runs JSON.stringify(value, null, 2), which re-emits the parsed data with two-space indentation, each object key and each array element on its own line, and a single space after every colon. Minify runs JSON.stringify(value) with no spacing argument, which produces the smallest valid representation. Both are lossless. Beautify and minify are perfect inverses — run one then the other and you are back where you started, because both describe the exact same object.

Format vs minify

Formatting and minifying are the same data at two different sizes, chosen for two different readers. You beautify for humans: when you are debugging, reviewing a diff, reading documentation or hand-editing a settings file, indentation is what lets your eye follow the nesting and spot the one wrong value. You minify for machines and the wire: when JSON is being sent over the network, stored in a database column, embedded in a URL or a data attribute, or shipped inside a JavaScript bundle, every space and newline is dead weight.

A useful habit is to keep the pretty version in your editor and minify only at the moment of sending or committing to a compact store. Because the round trip is lossless you never lose anything by switching between the two.

Catching JSON errors

JSON is strict, and that strictness is where most people get bitten. This tool surfaces the parser's own complaint so you can jump straight to the problem. The classic mistakes are nearly always one of these:

MistakeLooks likeFix
Trailing comma{"a":1,}Remove the comma before the closing brace or bracket — JSON, unlike JavaScript, forbids it.
Single quotes{'a':1}JSON keys and strings must use double quotes.
Unquoted key{a:1}Wrap the key in double quotes: {"a":1}.
Missing comma{"a":1 "b":2}Separate every pair with a comma.
Comment{"a":1 // note}Standard JSON has no comments — delete them.

When JSON.parse throws, browsers report a message such as Unexpected token } in JSON at position 8. That position is a character offset into your text, so counting to it lands you on or just after the culprit — usually a stray comma or a quote that was never closed. If validation passes, your JSON is syntactically correct.

When you need it

Doing it without this tool

Command line: jq . pretty-prints and validates in one step (jq . file.json), and jq -c . minifies. Without jq, Python is everywhere: python -m json.tool file.json formats and reports the first error.

Browser console: open DevTools and run JSON.stringify(JSON.parse(text), null, 2) to beautify or JSON.stringify(JSON.parse(text)) to minify — the very same calls this page makes. Editors: VS Code formats JSON with a keystroke and underlines syntax errors as you type.

All of these work well. This tool exists for the moment you just want to paste, see it formatted or validated, and copy the result — with no terminal, no install and nothing sent to a server.

Privacy: your JSON never leaves your browser

JSON is one of the riskiest things to paste into a random online formatter, because it so often carries the exact things you should never leak: API keys and bearer tokens, database connection strings, customer records, internal IDs and full request or response bodies. Many popular "JSON beautifier" sites POST your text to their own backend to format it — which means your secrets have touched a server you do not control, where they could be logged or cached.

This tool never does that. Parsing, beautifying and minifying all run in JavaScript on your device via JSON.parse and JSON.stringify. Open the network panel while you press a button and you will see zero requests leave the page; once it has loaded you can go offline entirely and it still works.

Related tools

URL encode / decodePercent-encode text for safe URLs, or decode %20-style URLs back to text.Hex converterTurn any text into its hexadecimal byte codes, or paste hex to read it back as…Title case converterCapitalises a headline properly — short words stay lowercase, unlike naive…Case converterSwitch between upper, lower, title, sentence, alternating and inverse case.Username generatorReadable names built from real words. No xX_ padding, no forced digits.Fancy fonts show boxesThose styled letters are separate Unicode characters, not styling. That…Dice rollerRoll a d6, a d20, two d6 or percentile dice. Sums included.

See all text tools →

Frequently asked questions

Does formatting change my data?

No. Beautify and minify only change whitespace, never values, key order within an object is preserved, and the two operations are exact inverses. The tool re-serialises the same parsed structure, so nothing about the actual content is altered.

Why does it say my JSON is invalid?

It means the browser's JSON.parse rejected your text, almost always because of a trailing comma, single quotes instead of double, an unquoted key, a missing comma, or a comment. The error message includes a character position — count to it to find the spot.

What is the difference between beautify and minify?

Beautify adds indentation and line breaks so a person can read the structure; minify strips all optional whitespace so the payload is as small as possible for storage or transfer. Both are lossless representations of the identical data.

Can it handle very large JSON files?

Yes, within the limits of your browser. Because everything runs locally, the constraint is your device memory rather than an upload cap, so multi-megabyte files usually format fine.

Does it support comments or trailing commas?

No, because standard JSON does not. Formats like JSON5 or JSONC allow comments and trailing commas, but strict JSON — the kind JSON.parse and most APIs expect — forbids both, and this tool validates against that strict standard.

Is my JSON sent anywhere?

No. All parsing and formatting happen in JavaScript on your own device, nothing is transmitted or logged, and you can confirm this by watching the network panel or disconnecting from the internet, after which the tool still works.

Why did the key order change after formatting?

It should not for ordinary objects — JSON.parse and JSON.stringify preserve insertion order for string keys. If you see numeric-looking keys reorder, that is a JavaScript engine rule for integer-like property names, not something the formatter chose to do.