devtools

JSON Formatter & Validator

Format, validate and minify JSON in your browser. Pretty-print with 2/4-space or tab indent, sort keys, and get parse errors with the exact line and column.

Runs entirely in your browser — your data never leaves your device.

How to use JSON Formatter & Validator

What it does & when you need it

You've pulled a JSON response from an API, a log line, or a config file, and it's a single unreadable line — or it won't parse and you can't see why. This tool pretty-prints JSON so you can actually read it, validates it against the JSON grammar, and when parsing fails it tells you the line and column where it broke. Everything runs in your browser using the same JSON engine your code uses, so a payload full of access tokens or customer data never leaves your machine.

How to use

  1. Paste your JSON into the input.json buffer, or press Sample to load an example. You can also Upload a .json file.
  2. The output updates as you type. Choose an Indent (2 spaces, 4 spaces, or a tab), toggle Sort keys for a canonical ordering, or hit Minify to collapse everything to one line.
  3. The input status bar shows valid JSON ✓ or the exact error position. Press Format (or Ctrl/Cmd + Enter) to re-run, and Copy to grab the result.

Things worth knowing

JSON is stricter than JavaScript. The format is defined by ECMA-404 and RFC 8259, and it does not allow the things editors let you get away with: no trailing commas, no comments, no single-quoted strings, and every object key must be a double-quoted string. If validation fails, one of those is almost always the reason.

Formatting never changes the data. Whitespace between tokens is insignificant, so minifying and pretty-printing produce byte-for-byte different text but the exact same parsed value. Minify for the wire, indent for humans. The one transformation that can change meaning is sort keys — it reorders object members (arrays are left alone), which is what you want before diffing two payloads but not if some downstream consumer wrongly depends on key order.

Numbers and duplicate keys have sharp edges. JSON numbers are IEEE-754 doubles, so an integer beyond 2^53 (a Twitter/X snowflake ID, say) loses precision the moment it's parsed — keep those as strings. And if an object contains the same key twice, the parser keeps the last one; this tool will show you the collapsed result, which is a quick way to catch a generator emitting duplicate keys.

Errors point at a location when the engine provides one. Modern JavaScript engines report a character position for most syntax errors, which the tool converts to a line and column. Some short-input errors omit the position; in that case you still get a plain-English message.

Once your JSON is clean, you might want to decode a JWT whose payload is JSON, or convert a Base64 string that contains an encoded JSON body.

Examples

Pretty-print a compact object

{"name":"Ada","born":1815,"fields":["math","cs"],"active":true}

Formats to indented, readable JSON with your chosen indent.

Catch a trailing comma

{
  "a": 1,
  "b": 2,
}

Trailing commas are invalid JSON — the tool reports where parsing failed instead of silently accepting it.

Frequently asked questions

Does this JSON formatter send my data to a server?

No. Parsing, formatting and validation all happen in your browser using the native JSON engine. Nothing you paste is uploaded, which matters when the JSON contains tokens or personal data.

Why does my JSON fail to validate?

The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, and comments — none of which are legal JSON (ECMA-404). The error message points to the line and column where parsing stopped.

What does "sort keys" do?

It recursively reorders every object’s keys alphabetically while leaving array order untouched. This makes two JSON documents diff cleanly and gives you a stable, canonical ordering.

Is minified JSON different data from formatted JSON?

No. Whitespace between tokens is insignificant in JSON, so minifying only removes spaces and newlines — the parsed value is identical. Minify for transport, pretty-print for reading.

Does formatting change numbers or key order?

Numbers are preserved as written (subject to JSON’s IEEE-754 double range), and key order is preserved unless you enable "sort keys". Duplicate keys are collapsed to the last value, per the JSON spec.