JSON & Data

JSON Formatter & Validator

Format, validate, beautify and minify JSON data online with precise error location. Works entirely in your browser.

Privacy: This tool runs entirely in your browser. Your data never leaves your device and is never uploaded to any server.

Formatted output will appear here.

How to use this JSON formatter

  • Paste or type your JSON into the input panel — it is validated as you go.
  • If something is wrong, the validator reports the line and column of the first syntax error.
  • Use Format to pretty-print with 2-space indentation, or Minify to strip every unnecessary space.
  • Copy the result with one click, or download it as a .json file.
  • Everything runs in your browser: nothing you paste is uploaded.

JSON versus a JavaScript object literal

JSON was derived from JavaScript, but it is not the same language. Code that runs perfectly in a .js file can be entirely invalid as JSON, which is why copy-pasting a config object so often fails.

SyntaxIn JSONIn JavaScript
Object keysMust be double-quotedQuotes optional
Trailing commasInvalidAllowed
CommentsNot part of the specAllowed
String quotesDouble quotes onlySingle or double
NaN and InfinityInvalidValid values
undefinedNot a valid valueValid
FunctionsCannot be representedValid

Formatting is not the same as validating

These are two different jobs that people often bundle together. Validating answers a single question: is this valid JSON at all? One misplaced comma makes the whole document invalid, and nothing downstream will be able to parse it.

Formatting — also called pretty-printing — makes no judgement about meaning. It only re-indents valid JSON so that a human can follow the nesting. A good formatter does both at once: it refuses to format invalid input, and tells you exactly where the problem is.

Why JSON breaks so easily

JSON looks like a JavaScript object literal, but it is far stricter. Almost every invalid document comes down to one of the same handful of mistakes:

  • Trailing commas — [1, 2, 3,] and {"a": 1,} are invalid, even though JavaScript tolerates them.
  • Unquoted keys — {name: "Ada"} must be {"name": "Ada"}.
  • Single quotes — JSON insists on double quotes, so 'text' is invalid.
  • Comments — // and /* */ are not part of the JSON specification.
  • Special numbers — leading zeros, NaN and Infinity are all invalid.

Common errors and what they usually mean

The validator points at the exact line and column, so you can jump straight to the character that caused it instead of scanning the whole document. In practice the message is usually one of these:

  • Unexpected token } in JSON — almost always a trailing comma.
  • Unexpected token ' in JSON — a single quote where JSON needs a double quote.
  • Unexpected end of JSON input — a closing bracket or brace is missing.
  • Unexpected token n in JSON — an unquoted key, or the literal NaN.

When should you minify?

Minifying removes whitespace that carries no meaning to a parser. It is worth doing whenever JSON has to travel over a network — API payloads, config bundles, cached data — because indentation can add 10% to 30% to the size of a deeply nested document.

Keep the readable, formatted version for humans and ship the minified one to machines. There is rarely a reason to send pretty-printed JSON between two programs.

Is it safe to paste JSON here?

Yes, and this matters more than it sounds. JSON frequently contains API keys, tokens, customer records and other sensitive data, and many online formatters quietly upload whatever you paste.

This one does not. Parsing, validation and formatting all happen in your browser using JavaScript, so your data is never transmitted, logged or stored. You can even disconnect from the network once the page has loaded and keep working.

Frequently asked questions

What is a JSON formatter?

A JSON formatter takes messy or minified JSON and reformats it with consistent indentation so it is easy to read and debug.

Is my JSON data uploaded to a server?

No. All formatting and validation happens locally in your browser. Your data never leaves your device.

How do I fix invalid JSON?

The validator reports the exact line and column of the first syntax error, so you can jump straight to the problem.

Is JSON the same as a JavaScript object?

No. JSON is a stricter text format. Keys must be double-quoted, comments and trailing commas are not allowed, and values such as undefined, NaN and Infinity cannot appear at all.

Does formatting change my data?

No. Pretty-printing and minifying only change the whitespace between tokens. No key, value or ordering is altered.

How large a file can I format here?

The parser runs in your browser, so the limit is your available memory rather than an upload size. Files of a few megabytes are usually fine; tens of megabytes will feel slow.

More JSON & Data tools