Skip to content
D DocNectar

Free JSON Formatter & Validator

Format, validate, minify and sort messy JSON — with clear error messages when it's invalid.

Built and fact-checked by the DocNectar team — see our editorial standards

Thanks for rating!

Key Features

Instant Calculation

Get accurate results in real time with our optimized algorithm.

Mobile Friendly

Fully responsive design. Works on all devices & screen sizes.

Privacy Focused

Your data stays on your device. We don't store any inputs.

100% Free

No hidden costs. This tool is completely free forever.

A single missing comma or an extra closing brace is enough to break a JSON parser, and the resulting error message isn't always specific about where the problem is. This formatter validates your JSON and, if it's invalid, tells you exactly what went wrong (PHP's own json_last_error_msg(), not a vague generic message). If it's valid, it pretty-prints it with the indent width you choose, minifies it to a single compact line, or sorts every object's keys alphabetically — whichever you need.

It's built for debugging API responses, cleaning up config files, and turning minified JSON back into something readable, without installing anything or pasting sensitive data into an unfamiliar site's clipboard-adjacent text box.

How it works

Paste your JSON into the input box, choose pretty-print or minify, set an indent width if you're pretty-printing, and optionally sort keys alphabetically. If the JSON is invalid, you'll get a specific parse error instead of a formatted result. If it's valid, you get the formatted output plus quick stats: size before and after, how many object keys it contains, and how deeply nested it is.

  1. Paste your JSON into the input box.
  2. Choose pretty-print (with an indent width) or minify.
  3. Optionally sort object keys alphabetically.
  4. Click Format to validate and see the result, or a specific error if it's invalid.

Examples

Minified API response

An API returns `{"user":{"id":1,"name":"Jane","roles":["admin","editor"]}}` on one line. Pretty-printing it with a 2-space indent turns it into a readable, properly nested structure in one click.

Invalid JSON from a hand-edited config file

A config file with a trailing comma — `{"debug": true,}` — fails to parse in strict JSON parsers. The formatter reports the specific syntax error instead of silently failing or showing a generic message.

Who should use it

  • Debugging an API response by making it readable.
  • Cleaning up or reformatting a hand-edited configuration file.
  • Minifying JSON before embedding it somewhere size-constrained.
  • Sorting keys to make two JSON documents easier to diff.

Industry applications

  • API development and debugging
  • DevOps and configuration management
  • Frontend/backend integration work
  • Data engineering and ETL pipelines

Advantages

  • Gives a specific parse error instead of a generic "invalid JSON" message.
  • Supports pretty-print with a custom indent, minify, and alphabetical key sorting in one tool.
  • Reports size, key count and nesting depth alongside the formatted output.

Limitations

  • Validates strict JSON only — doesn't support JSON5/JSONC comments or trailing commas.
  • Doesn't validate against a JSON Schema, only that the syntax itself is well-formed JSON.
  • Very large payloads (near the size cap) may be slower to process than a native desktop tool.

Common mistakes to avoid

  • Using single quotes instead of double quotes around strings and keys — valid in JavaScript object literals, invalid in strict JSON.
  • Leaving a trailing comma after the last item in an object or array.
  • Forgetting to escape special characters (like unescaped quotes) inside string values.
  • Mixing up JSON with JSON5/JSONC (which allow comments and trailing commas) — this tool validates strict JSON only.

Best practices

  • Validate JSON before committing it to a config file or API contract, not after something downstream fails to parse it.
  • Pick a consistent indent width across a project's config files rather than mixing tabs and varying space counts.
  • Use minify mode for JSON that will actually be transmitted over the network, and pretty-print only for human reading/editing.
  • Sort keys when diffing two versions of the same JSON structure — it makes the diff much easier to read.

Tips

  • If you're not sure why your JSON is invalid, check for trailing commas and single-quoted strings first — they're the most common cause.
  • Sort keys before diffing two versions of a JSON file in git — it turns a noisy diff into one that only shows actual changes.

Frequently asked questions

Yes, with no signup and no limit on how much you format.
Any width from 1 to 8 spaces when pretty-printing. Use minify mode instead if you want a single compact line.
Common causes are trailing commas, single quotes instead of double quotes, unescaped control characters, or an unclosed bracket/brace — strict JSON (unlike JavaScript object literals) doesn't allow trailing commas or single-quoted strings.
No — object key order isn't meaningful in the JSON spec, so alphabetizing keys is purely cosmetic and safe for any conforming JSON consumer. (Array order does matter and is left untouched.)
It's processed to generate the formatted result and linked to your browser session so you can revisit recent ones — it isn't shared with anyone else.
How many levels of nested objects/arrays your JSON has. A flat object is depth 1; an object containing an object containing an object is depth 3. Very deep nesting can be a sign a data structure has gotten more complex than necessary.

Get new calculators and guides in your inbox

No spam — just new tools like JSON Formatter and practical guides.

Favorites