JSON Formatter & Validator

Paste JSON to format or minify it. Indent with tabs or 2, 4, or 8 spaces. If parsing fails, you get the exact line and column, not just a character offset. We use a background thread for large files so your browser stays responsive.

Input size: 0 B

Output size: 0 B

What the error messages actually mean

What you seeWhat it usually is
Unexpected token }A trailing comma before the closing brace. JSON does not allow one.
Unexpected token 'Single quotes. JSON strings use double quotes, always.
Unexpected token /A comment. JSON has none. That is JSONC or JSON5.
Unexpected end of inputA brace or bracket never closed, often because the file was truncated.
Unexpected token NNaN or Infinity, which JSON cannot represent.
Unexpected non-whitespace after JSONTwo documents in one file, or a stray character after the final brace.

Chrome reports many of these without a position at all. This tool recovers the line and column from the quoted excerpt, so you get somewhere to look rather than a character offset into a file you cannot count through.

Choosing an indent

IndentWhere it is the convention
2 spacesnpm, most JavaScript tooling, the majority of API examples
4 spacesPython projects, .NET configuration, many corporate style guides
TabGo projects, and anywhere the file is read at several zoom levels
MinifiedAnything sent over a network: whitespace is bytes

None of this changes the data. Two JSON documents that differ only in whitespace are the same document, which is why minifying before sending and formatting before reading costs nothing.

What JSON deliberately leaves out

Most invalid JSON is valid JavaScript, which is the root of the confusion. The format is a strict subset on purpose. Every omission removes an ambiguity between parsers.

  • No comments. There is no agreed way to preserve them, so round-tripping a file would silently lose them.
  • No trailing commas. Some parsers ignored them and some counted an extra empty element.
  • No single quotes, and keys must be quoted.
  • No NaN, Infinity or undefined. Use null, or a string if the distinction matters.

If you want the conveniences, JSON5 and JSONC exist and have their own parsers. What you cannot do is feed them to something expecting JSON.

Frequently asked questions

Is my JSON uploaded to a server?

No. Parsing and formatting happen in your browser. The site’s security policy sets connect-src ‘none’, so the browser blocks network requests from these pages. You can confirm it in the Network tab.

Why does Chrome sometimes not say where the error is?

Chrome reports a lot of parse errors as "Unexpected token … is not valid JSON" and gives no position. This tool works the location out from the quoted excerpt, so you still get a line and column.

Does it accept comments or trailing commas?

No, because JSON itself does not allow them. They are a common reason a file will not parse. JSONC and JSON5 are separate formats and need their own parsers.

How large a document can it handle?

A 5 MB file formats without freezing the page, because parsing runs on a background thread. Past that the limit is your device’s memory.