Format

JSON Formatter & Validator

Format, validate, and minify JSON instantly. Precise error messages with line numbers. Pretty print or compact output with one click.

Paste JSON to validate it instantly. Common issues like trailing commas, comments, and unquoted keys are called out with precise hints.

Formatted output appears here

Paste JSON on the left to validate and format it

Common JSON syntax issues

Trailing commas

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

Single-quoted strings

{ 'key': 'value' }
{ "key": "value" }

Unquoted keys

{ key: "value" }
{ "key": "value" }

Comments

{ "a": 1 // comment }
{ "a": 1 }

JSON vs JavaScript object literal

JSON is a data interchange format, not JavaScript syntax. Key differences: all keys must be double-quoted strings, no trailing commas, no comments, no undefined values, no functions, no NaN or Infinity (use null instead). Valid JavaScript object literals are often not valid JSON.

Formatting (pretty-printing) adds consistent indentation and newlines to make JSON human-readable without changing the data. Validating checks that the JSON conforms to the specification — balanced braces, quoted keys, no trailing commas, no comments. This tool does both simultaneously.

The most common causes: trailing commas after the last item in an array or object (not valid in JSON, unlike JavaScript), single-quoted strings (JSON requires double quotes), comments (JSON has no comment syntax), and unquoted property keys (all keys must be double-quoted strings).

Minification removes all whitespace (spaces, newlines, indentation) that isn't part of a string value. The result is semantically identical but smaller. Useful for reducing payload size in API responses or storage. This tool's minify output is the canonical compact form.

Standard JSON (ECMA-404) does not support comments. If you need JSON with comments for config files, consider JSONC (JSON with Comments, used by VS Code) or JSON5 — both are supersets of JSON. Parsing these with a standard JSON parser will fail.

There is no hard limit — the parser uses the browser's native JSON.parse(), which can handle very large documents. For extremely large files (100MB+), performance depends on your device. For production processing of large JSON, use a streaming parser.

The JSON is incomplete — there are unclosed brackets, braces, or strings. Check that every { is closed by }, every [ by ], every " by another ". Copy the input into an editor with bracket matching to find the issue quickly.