JSON Formatter

Format, beautify and minify JSON with instant validation — all in your browser.

Runs in your browserUpdated Built and maintained by Leon and Henrik

Beautify, validate and minify JSON instantly — everything stays in your browser. Free. No sign-up. Runs in your browser, nothing is uploaded.

JSON Formatter
Indent

Output

Your formatted JSON will appear here.
Runs in your browser
Nothing is uploaded

Paste JSON and press Format to pretty-print it with 2 or 4 spaces, or Minify to squeeze it onto one line. If it is not valid, you get the parser's message plus the line and column where it broke, so you can jump straight to the problem. The indent width is remembered for next time; your JSON is not.

Error messages and what usually causes them

The message comes from your browser's JSON parser, so the wording differs a little between Chrome, Firefox and Safari. The underlying causes are always the same handful:

Message mentions…Usual causeExample
"Expected double-quoted property name"A trailing comma before }{"a": 1,}
Expected property name or '}'A key without quotes, or in single quotes{a: 1} or {'a': 1}
"Unexpected token" followed by a quote 'A single-quoted value{"a": 'x'}
"Unexpected token" at the very startText before the JSON: a log prefix, data: , a BOMdata: {"a":1}
"Unexpected end of JSON input"A bracket or brace never closed, or a truncated copy{"a": [1, 2}
Expected ',' or '}' after property valueMissing comma between two entries{"a": 1 "b": 2}
"Bad control character in string"A real line break or tab inside a stringUse \n instead
"Unexpected token" at N, u or INaN, undefined or Infinity — not JSON values{"x": NaN}

The line and column point to where the parser gave up, which is often one character after the real mistake. With a missing comma, look at the end of the previous line.

JavaScript object or JSON? The differences that bite

Copying an object straight out of code is the most common reason a paste fails. JSON is stricter than JavaScript:

  • Keys need double quotes: {"name": "x"}, never {name: "x"}.
  • Strings need double quotes: 'hello' is not JSON.
  • No trailing commas in arrays or objects.
  • No comments, neither // nor /* */.
  • Only six value types: string, number, true/false, null, array, object. No undefined, NaN, dates or functions — dates travel as strings such as "2026-11-30".

Things formatting quietly changes

Formatting re-prints the parsed data, so a few details of your original text are not preserved:

  • Number spelling is normalized. 1.0 becomes 1, 1e2 becomes 100, -0 becomes 0.

  • Unicode escapes are written out. "café" comes back as "café". It is the same string, but a text diff will flag it.

  • Duplicate keys collapse to the last value, as described in the FAQ.

  • Huge integers lose digits. The tool warns you whenever a whole number above 2^53 − 1 is in the input. Numbers too large or too small for JavaScript at all (like 1e400) trigger a separate warning, because they turn into null or 0.

  • Number-like keys move to the front. Key order is otherwise kept as written, but JavaScript always lists integer keys first and in ascending order: {"b": 1, "2": 0, "1": 0} comes out as {"1": 0, "2": 0, "b": 1}.

2 spaces, 4 spaces or minified?

  • 2 spaces is the common default in JavaScript projects and API documentation, and keeps deep nesting from running off the right edge.
  • 4 spaces is easier to scan for shallow, wide objects and matches what Python writes with json.dumps(data, indent=4).
  • Minified is for sending and storing. Deeply nested, indented JSON can spend a surprising share of its bytes on spaces and line breaks; minifying removes all of them. Gzip compression on a server narrows that gap, so the gain matters most for stored files and size-limited fields.

If the JSON lives in a Git repository, keep it pretty-printed with one consistent indent: a change then shows up as a one-line diff instead of one giant modified line.

Switching between 2 and 4 re-indents the current output straight away. Pasting a minified blob, formatting it to read, then minifying it again before pasting it back is the everyday workflow.

Next steps for the same data

Need the data in another shape? The JSON ↔ CSV Converter turns an array of objects into a spreadsheet, the JSON ↔ YAML Converter handles config files, and JSON to TypeScript writes interfaces from a sample payload.

Frequently asked questions