← All tools

JSON Formatter & Validator

Paste JSON, get it pretty-printed or minified — and when it is broken, the exact line and column of the mistake.

How it works

Everything happens in one pass inside your tab. The text you paste is handed to the browser's own JSON.parse, which implements the grammar from RFC 8259 — the same parser Chrome, Firefox and Safari use for every fetch().json() call, so "valid here" means "valid in your application". If parsing succeeds, the resulting value is re-serialised with JSON.stringify using the indentation you picked: two spaces, four spaces, or a single tab character per level. Minify does the same round trip with no indentation at all, which also strips every insignificant whitespace character between tokens.

When parsing fails, the error message contains a character offset such as position 57. The tool walks the original text up to that offset, counting newlines to turn the offset into a human line and column number, then reports both. A file that is 40 000 characters wide on one line is therefore reported as line 1, column 39 999 — the offset is the fact, the line break is only how it is displayed. "Sort keys" rebuilds objects recursively with Object.keys().sort() (plain UTF-16 code-unit order, so Z comes before a), which is handy for diffing two configs that were written in different orders.

A small statistics line reports the byte length before and after (UTF-8, so non-ASCII characters count for more than one byte), the percentage change, the top-level type, and how deeply the structure nests. Depth is computed by recursion over objects and arrays; an empty object is depth 1.

What this tool does not do

It is not a lossless copy. Parsing and re-serialising normalises the document, so some things change: 1.0 becomes 1, 1e3 becomes 1000, duplicate keys collapse to the last one, and \/ becomes /. Integers larger than 253 lose precision, because JavaScript numbers are IEEE 754 doubles — if you exchange 64-bit IDs, keep them as strings. Key order is preserved only for non-numeric keys; keys that look like array indices ("0", "12") are always moved to the front by the language itself, so "Sort keys" cannot fix those.

It does not accept JSON5, JSONC, comments, single quotes, trailing commas or NaN/Infinity — those are not JSON, and the parser will reject them with a position, which is the correct behaviour. It does not validate against a JSON Schema, does not convert to YAML or CSV, does not fetch a URL for you, and does not fix malformed input automatically: guessing what you meant is how silent data corruption starts. Nothing is uploaded, logged or stored — there is no server to send it to.

Runs entirely in your browser. Nothing you paste is uploaded — you can disconnect from the network after the page loads. Tokens, keys and customer data stay on your machine.

Related tools

All small tools · Age Calculator · Token Counter