JSON Formatter & Validator

Paste JSON to format, validate or minify it instantly in your browser.

Indent:

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is based on a subset of JavaScript and is language-independent.

Format

Prettify minified JSON with configurable indentation for readability.

Validate

Check JSON syntax instantly — parse errors are highlighted with a description.

Minify

Remove all whitespace to produce compact JSON ready for production or APIs.

How to format and validate JSON

  1. Paste your JSON into the input box. It's parsed as you type.
  2. If it's valid, the formatted version appears on the right with a green badge. If not, you'll see the parser's error message.
  3. Switch between 2 and 4 spaces of indentation, or press Minify to strip all whitespace.
  4. Copy the result with one click.

The mistakes that break JSON most often

JSON looks like JavaScript, and that's exactly why it's easy to get wrong: plenty of things that are fine in a JavaScript object literal are syntax errors in JSON. These five account for most "invalid JSON" messages we see:

MistakeInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'b'}{"a": "b"}
Unquoted key{a: 1}{"a": 1}
Comments{"a": 1 // note}{"a": 1}
Special values{"a": undefined}{"a": null}

Two subtler ones: NaN and Infinityaren't allowed either, and strings can't contain raw line breaks or tabs. They have to be escaped as \n and \t. If you copied JSON out of a log line or a chat message, watch out for "smart" curly quotes too; they look like normal quotes but aren't.

Pretty-print or minify?

Pretty-printed JSON is for people: reading an API response, reviewing a config change, or diffing two payloads. Minified JSON is for machines. Whitespace adds nothing for a parser, and on a large document it can account for a fifth or more of the bytes. That said, if your server already compresses responses with gzip or Brotli, the gain from minifying shrinks to a few percent, because whitespace compresses extremely well.

Formatting JSON elsewhere

For a quick reformat without leaving the terminal or editor:

  • jq: jq . data.json pretty-prints; jq -c . data.json minifies.
  • Python: python -m json.tool data.json.
  • Node.js: JSON.stringify(JSON.parse(text), null, 2) is exactly what this page does.
  • VS Code: open the file and press Shift+Alt+F (Shift+Option+F on macOS).

This page is handiest when you're holding JSON in your clipboard, say from a browser's network tab, a log aggregator or a support ticket, and just want to read it.

Frequently asked questions

Why does my JSON say "Unexpected token"?+

The parser hit a character it didn't expect at that position. The usual suspects are a trailing comma after the last item, single quotes instead of double quotes, an unquoted key, or a comment. The error message tells you the position, which is the place to look first.

Does JSON allow comments?+

No. Standard JSON has no comment syntax, so // and /* */ cause a parse error. Formats like JSONC (used by VS Code settings) and JSON5 allow them, but they aren't valid JSON and most APIs will reject them.

Should I use 2 or 4 spaces?+

It's a style choice. Two spaces is the most common convention in JavaScript projects, package.json and most API documentation. Four spaces reads better for deeply nested data. Pick whatever matches the rest of your codebase.

Will formatting change my data?+

The structure and values stay the same, with two caveats inherent to JavaScript's JSON parser. Integers larger than 2^53 (about 9 quadrillion) lose precision, and if an object repeats a key only the last value is kept. Keep that in mind with 64-bit IDs.

Is it safe to paste API responses or config files here?+

Yes. Parsing and formatting happen in your browser with JSON.parse and JSON.stringify. Nothing you paste is uploaded or stored, so tokens and personal data in the payload stay on your machine. Still, rotate any secret you've pasted somewhere you didn't intend to.

Last updated October 16, 2026