Tools

JSON formatter and validator

Paste JSON to pretty-print it, minify it, or find out exactly where it breaks. Error messages point at the line and column, not just 'invalid JSON'.

JSON is parsed by your browser's own engine inside this page. API responses, tokens and config files you paste here are never transmitted — which is the point.

How to use this JSON formatter

Paste JSON into the input box and choose an action. Format pretty-prints it with consistent indentation. Minify strips every unnecessary byte. Validate only checks the syntax without producing output, which is what you want when you just need to know whether a file is well-formed.

All three parse the input first, so all three tell you if the JSON is broken — and they tell you where.

Error messages that point at the problem

Browsers report JSON syntax errors as a character offset, which is close to useless when you are staring at a 4,000-line API response. This tool converts that offset into a line and column number, so "Invalid JSON at line 847, column 23" gets you straight to the fault.

The errors you will hit most often, in rough order of frequency:

  • Trailing comma. {"a":1,} is valid JavaScript and invalid JSON. This is the single most common cause, especially in hand-edited config files.
  • Single quotes. JSON requires double quotes for both keys and string values. {'name':'test'} is a JavaScript object literal, not JSON.
  • Unquoted keys. {name:"test"} is likewise valid JavaScript and invalid JSON. Keys must always be quoted strings.
  • Comments. JSON has no comment syntax. // and /* */ both fail. If you need comments in configuration, use JSON5, YAML or TOML.
  • NaN, Infinity or undefined. None of these exist in JSON. Numbers must be finite, and absence is expressed with null.
  • Unescaped characters inside strings. A literal newline, tab or unescaped double quote inside a string value breaks the parse. They must be written as \n, \t and \".

Sorting keys

Tick "Sort keys A→Z" and every object in the structure, at every depth, is reordered alphabetically. This is the trick that makes two JSON files diffable. API responses often serialise keys in non-deterministic order, so a naive diff between two captures shows dozens of false changes. Sort both files, format both with the same indentation, and the diff shows only what actually differs.

Escape and unescape

These two handle a specific and annoying situation: JSON embedded inside JSON. When one system stores a JSON document as a string field inside another JSON document, you get output full of \" sequences that no formatter will parse.

Unescape string takes that mess and gives you back the real JSON, which you can then paste in again and format normally. Escape as string does the reverse — it turns your JSON into a properly escaped string literal ready to be embedded in another document, a shell script, or a test fixture.

The structure statistics

After a successful parse you get four numbers: total keys across all objects, maximum nesting depth, total value count, and the minified byte size. Depth is the one worth watching. Anything past five or six levels is usually a sign that a data model has grown organically rather than by design, and it makes both the code that consumes it and the humans who read it work harder than they should.

The minified size tells you what the payload actually costs on the wire, before HTTP compression. Formatting exists for humans; every byte of indentation in a production API response is pure waste, which is why every serious API minifies.

Why doing this locally matters

The JSON people need to format is very often exactly the JSON they should not paste into a random website: an API response containing customer records, a config file with database credentials, a decoded JWT with session claims, a webhook payload with personal data.

This page has no server component. The parsing is done by JSON.parse(), which is built into your browser. Load the page once and you can work with the network disconnected — and if your organisation's policy forbids pasting internal data into external services, a tool that provably makes no network request is the one that keeps you compliant.

Frequently asked questions

Why does my JSON say invalid when it looks fine?

In roughly that order: a trailing comma before a closing brace or bracket, single quotes instead of double quotes, unquoted keys, or a comment. All four are valid JavaScript and none of them are valid JSON. The error message here gives you the line and column so you can go straight to it.

Can JSON have comments?

No. The specification has no comment syntax, and every conforming parser rejects them. If you need commented configuration, use JSON5, YAML or TOML — or keep a separate documentation file and strip comments before parsing.

What is the difference between formatting and minifying?

Formatting adds whitespace and line breaks so a human can read the structure. Minifying removes every byte that is not required by the syntax. The parsed data is identical either way — only the presentation and the byte count change.

Is my JSON sent to your server?

No. Parsing uses your browser's built-in JSON.parse(). There is no server call anywhere on this page, which is why it keeps working with your connection turned off. That is deliberate — the JSON people most need to format is usually the JSON they least want to upload.

How do I fix JSON that has escaped quotes everywhere?

That is JSON stored as a string inside another JSON document. Paste it into the input and press "Unescape string" to recover the real structure, then press Format on the result.

Does it handle very large files?

It handles anything your browser can hold in memory — files of several megabytes are fine on a desktop. Very large files will make the textarea itself feel sluggish, since browsers are not optimised for rendering megabytes of text in a single input, but the parse itself stays fast.