Skip to content
OmniTools

JSON Formatter & Validator

Pretty-print, minify, and validate JSON with precise error locations.

All developer tools

JSON formatter & validator

Indentation
Result

This tool runs entirely in your browser. Nothing you enter is uploaded, stored, or logged.

What this tool does

Unformatted JSON is close to unreadable once it nests more than a couple of levels, which makes reviewing an API response or a config file tedious. This tool reformats JSON with your chosen indentation, validates it, and reports exactly where a syntax error is rather than just that one exists.

How it works

Formatting and minifying are structural edits, not text edits. The JSON is parsed into a tree of values, then re-serialised with the indentation you choose. Because it round-trips through a parser, the output is guaranteed to be valid JSON, and it also means comments or trailing commas that a permissive parser might accept are normalised away rather than silently preserved.

Validation errors carry a position, not just a message. The browser's parser reports where it gave up and what it expected, which is usually enough to locate a missing comma, an unquoted key, or a trailing comma in one pass instead of hunting by eye.

A 64-bit number cannot be represented exactly by JavaScript's number type, so very large integers or precise decimals will be reformatted with a different value. If your JSON contains identifiers or amounts that must survive byte-for-byte, keep a copy of the original rather than relying on a reformat.

Worked example

Repairing a payload that a server rejected: {"id":7,"tags":["a","b"],"meta":{"ok":true,}}

  1. The trailing comma after true is a syntax error in strict JSON
  2. Remove the trailing comma
  3. Parse succeeds, then re-serialise with two-space indentation

A valid, readable object. Keeping the trailing comma works in JavaScript object literals but is invalid in a JSON document, which is a common source of rejected uploads.

Accuracy and limitations

  • Numbers beyond JavaScript's safe integer range (2^53 - 1) will be reformatted and may change value. Keep the original if exactness matters.
  • Comments are not valid JSON. JavaScript object literals allow them, JSON documents do not.

Frequently asked questions

Why does my valid-looking JSON fail to parse?
Most often a trailing comma, a single-quoted string, an unquoted key, or a comment. All of those are legal in a JavaScript object literal but not in a JSON document. The error position in this tool points at the exact character where parsing stopped.
Does formatting change the data?
Not for ordinary values. It does change very large numbers, because JSON numbers become JavaScript numbers and anything past 2^53 - 1 cannot be held exactly. For IDs, timestamps in nanoseconds, or exact monetary values, keep the original text.
Why is my JSON rejected but accepted in JavaScript?
Because they are different formats. JSON is a strict subset: no comments, no trailing commas, no unquoted keys, no single quotes, and the top level must be an object or array rather than a bare string or number.
Is my JSON sent to a server?
No. Parsing and re-serialising happen in your browser, so pasting a production payload or a config file containing secrets is safe from this tool's perspective.