JSON Formatter & Validator

Client-sideNo sign-upFree

Beautify, validate, and minify JSON instantly in your browser.

Quick facts

Category
Formatters & Beautifiers
Best for
Debugging malformed API responses
Input
✓ Valid JSON
Formatted output
{ "id": 1, "name": "Formatiq", "tags": [ "json", "tools" ], "active": true }
9 lines
Just need a pass/fail syntax check without reformatting? Use the JSON Validator. Comparing two JSON documents? See the JSON Diff Checker. Converting to or from XML? Try the XML to JSON Converter.
In-content slot
Was this tool helpful?

JSON looks simple until a single missing comma or stray quote breaks a build. This guide covers the syntax rules a formatter enforces, the errors it catches, and how to read the output.

On this page

What "formatting" JSON actually does

Formatting takes JSON text - valid or not visually organized - and re-serializes it with consistent indentation and line breaks, so nested objects and arrays are easy to scan. It does not change the data: the same keys, values, and structure go in and come back out, only the whitespace around them changes. A separate step, validation, checks whether the text is syntactically legal JSON in the first place; a formatter that also validates will refuse to reformat text that fails that check and instead reports where it broke.

The rules JSON syntax enforces

  • Object keys must be double-quoted strings - single quotes and unquoted keys are invalid JSON, even though both are legal in JavaScript object literals.
  • Trailing commas are not allowed after the last item in an array or the last property in an object.
  • Strings must use double quotes; escape a literal double quote inside a string as \".
  • Numbers cannot have leading zeros (01 is invalid) and cannot be NaN, Infinity, or written as hex.
  • Every opening brace, bracket, and quote needs a matching close - the most common real-world failure is one of these left unclosed after editing by hand.

Before and after: a typical minified API response

APIs commonly return JSON with no whitespace at all, which is efficient to transmit but unreadable to a person debugging a response. Formatting with 2-space indentation turns this:

{"id":1,"name":"Ada Lovelace","roles":["admin","editor"],"active":true}

into this:

{
  "id": 1,
  "name": "Ada Lovelace",
  "roles": [
    "admin",
    "editor"
  ],
  "active": true
}
The reverse operation - minifying - strips exactly this whitespace back out. It is useful when you want the smallest possible payload (e.g. embedding config JSON in a URL or a build artifact) rather than something readable.

Common errors and what they mean

Error message patternTypical causeFix
Unexpected token } / Unexpected end of JSON inputA trailing comma before a closing brace or bracket, or a value cut off mid-editRemove the trailing comma, or complete the truncated value
Unexpected token 'Single-quoted string or key (valid in JS, not in JSON)Replace single quotes with double quotes
Unexpected non-whitespace character after JSONTwo JSON values concatenated (e.g. two objects pasted back to back) instead of one root valueWrap them in an array, or format them one at a time
Bad control character in string literalA raw newline or tab pasted inside a string instead of the escaped \n / \tEscape the character or remove it

Frequently asked questions

No - the parsing and formatting happen locally in your browser’s JavaScript engine, not on a server. That matters in practice because people often paste things here that shouldn’t leave their machine: a production API response with real customer data, an internal config file with connection strings, or an auth token buried in a payload. None of it is transmitted anywhere; it’s the same as opening the text in a local editor.

The validator shows the specific parsing error and its position, most commonly a missing comma, an unclosed bracket, or a trailing comma before a closing brace.

Yes - use the "Minify input" button to collapse your JSON to a single compact line, useful for reducing payload size before sending it over the wire.

Explore more free tools

Formatters, converters, validators, and generators - all free and running entirely in your browser.

Browse more tools