🔧 TL3 Tools

📋 JSON Formatter & Validator

Written by Jane Smith · Reviewed by Alex Chen · July 15, 2026

Format, minify, and validate your JSON data with syntax error detection. Formatting is done entirely within your browser.

Input

Output

Keys: 0Chars: 0

What a Formatter Is For

Paste any JSON document into the left box and this page re-emits it in one of three shapes: pretty-printed with your choice of 2-space, 4-space, or tab indentation; minified onto a single line; or validated with a yes/no verdict. The people who reach for it are the ones staring at a wall of machine-generated JSON from an API, a config file, or a data export who need to actually read what is inside. The output panel also tallies the number of keys in your document and the character count of the result, which turns a quick inspection into a measurable one.

Format, Minify, or Validate: One Parser, Three Buttons

All three actions run the same underlying step: the browser's native JSON.parse(), which is the same strict parser every JavaScript application uses. Format re-serializes the parsed object with JSON.stringify() using the indentation you picked from the dropdown. Minify calls the same serializer with no indentation at all, producing the smallest valid form. Validate parses and discards, showing a green badge for valid input or a red one alongside the parser's own error message for invalid input. The key counter walks the parsed object recursively, adding every property at every level of nesting, while the character counter measures the output pane's text length.

A Nested Object, Before and After

Feed this compact document in:

{"user":{"name":"Ada","role":"engineer"},"active":true}

That single line is 55 characters. Clicking Format with 2-space indentation produces:

{
  "user": {
    "name": "Ada",
    "role": "engineer"
  },
  "active": true
}

The pretty version runs to 79 characters — the extra 24 are pure indentation — while 4-space comes to 93 and tab stops somewhere in between, proving the content is identical and only the whitespace budget changes. The key counter reports 4, because the object contains user, name, role, and active at two different depths. Clicking Minify on the pretty output folds it back to the original 55-character line, so the round trip is lossless.

What the Formatter Won't Tell You

The parser is deliberately strict. Comments, trailing commas, single-quoted strings, and unquoted keys all fail, and Format responds with the error position rather than output — for example, a stray comma before a closing brace produces Error (line 1, col 41): Expected double-quoted property name in JSON at position 40 (line 1 column 41). The parse-and-reserialize path also normalizes what it touches: the number 1.0 comes back as 1, an escape like \u0041 is decoded into the letter A, and if your object lists the same key twice, only the last value survives. None of this changes the data's meaning, but if byte-for-byte fidelity with the original text matters, keep the source file rather than re-exporting it from here. Documents in the several-megabyte range work, though very large ones may pause the tab.

Questions About Formatting JSON

What exactly does the key count include?

Every own property at every depth, counted recursively. The sample above scores 4 even though only two keys sit at the top level, because the nested user object contributes name and role as well. Arrays contribute nothing toward the total — only object properties are keys.

Why does Format sometimes fail on data that looks fine?

Almost always a strictness violation: a trailing comma, a comment, or a single-quoted string. JSON allows only double quotes and no trailing punctuation, and the parser quotes the exact character position of the first offense, so the error message doubles as a map to the fix.

Does Formatting change my data?

The meaning is preserved, but the text is normalized on the way through the parser: numbers like 1.0 become 1, escape sequences are resolved into their actual characters, and duplicate keys collapse to their last occurrence. For display and debugging that is a feature; for byte-exact round trips it is a reason to keep the original.

Why is my pretty-printed version so much longer than the minified one?

Because every nesting level adds indentation characters plus a line break, and those are pure overhead once the structure is understood. On the sample above the 2-space form is 79 characters versus 55 minified, roughly 44% more, and the gap grows as nesting deepens.

Is it safe to paste confidential JSON here?

Yes — parsing and serialization run entirely in your browser tab, and the page never uploads your document anywhere, so tokens and internal payloads stay on your machine.

When to Format and When to Leave It Alone

Use this page when you need to read a JSON blob someone handed you — an API response, a configuration dump, a database export — or when you want to shrink a payload that only carries whitespace fat. Leave it alone when your file is JSON5 or JSON with comments, which no strict parser will accept; when you are streaming a file larger than memory comfortably holds; or when you are in a terminal and jq or python -m json.tool would get the job done without a browser. For YAML, the sibling converter on this site handles the translation instead.

Related Tools