JSON Formatter & Validator

Beautify or minify JSON and see exactly where a syntax error is.

0 characters

Or drop a .json/.txt file onto the box above.

Action
View
Indent
Keys

How to use

  1. Paste JSON into the left box. It is parsed on every change, so there is nothing to press.
  2. Choose Format for indented output or Minify for one line; under Indent, pick 2 spaces, 4 spaces or Tab.
  3. Tick Sort keys alphabetically when two documents need to be compared side by side.
  4. If the input is invalid, the failing line is marked red in the input box and the status bar gives the line and column; click the status bar to jump there. The output appears as soon as the JSON parses.
  5. Copy to clipboard or Download .json. Ctrl+Enter in the input box also copies.

What this tool checks

JSON looks like JavaScript but is stricter: keys must be double-quoted, trailing commas are not allowed, and values are limited to strings, numbers, booleans, null, objects and arrays. A single misplaced comma or a stray single-quote is enough to break a whole payload, and the resulting error from most languages' JSON parsers only gives a byte offset. This tool converts that into a line and column you can actually find, and beautifies valid JSON so nested structures are easy to read.

Minifying does the opposite: it strips every non-significant space and newline, which is what you want before sending JSON over the wire or pasting it into a field with a size limit. Both directions use the browser's native parser, so a 4 MB document formats in around a tenth of a second on a laptop, and typing is debounced so the page never stalls mid-keystroke.

Example

Paste a compact object:

{"name":"Ada","born":1815,"tags":["math","writer"]}

and Format produces:

{
  "name": "Ada",
  "born": 1815,
  "tags": [
    "math",
    "writer"
  ]
}

Options explained

Edge cases and common errors

Do the same thing in code

JavaScript

const pretty = JSON.stringify(JSON.parse(text), null, 2);
const compact = JSON.stringify(JSON.parse(text));

Python

import json
pretty = json.dumps(json.loads(text), indent=2)
compact = json.dumps(json.loads(text), separators=(",", ":"))

Shell

jq . file.json        # pretty-print (jq)
jq -c . file.json     # compact
python -m json.tool file.json

JSON Formatter & Validator FAQ

Is my JSON uploaded to a server?

No. Parsing and formatting happen with the browser’s own JSON engine, on your device. Nothing you paste is sent anywhere, which matters when the JSON contains API keys, tokens or customer data.

How do I find exactly where a syntax error is?

When the input is invalid, the result panel shows the line and column of the problem, plus a short description such as a missing comma or an unquoted key. Trailing commas and single-quoted keys are the two most common causes.

What does “Sort keys alphabetically” do?

It reorders every object’s keys (recursively, at every nesting level) alphabetically without changing any values. Useful for diffing two JSON files where only the key order differs.

Can I format a single value, like just a number or a string?

Yes. 42, "hello" and true are all valid JSON documents on their own, and the formatter accepts them.

Why does a large number come out changed?

JSON numbers are read as 64-bit floating point, so integers above 253 (about 9 quadrillion) lose their last digits. If an ID that large must survive, store it as a string in the source system. The formatter cannot recover digits the parser has already rounded.

Runs entirely in your browser: this page is a static file with no server behind it, so nothing you paste can be uploaded. Last reviewed by Parthesh Gupta. Implements RFC 8259 (JSON).