GitGudgit gud
gitgudRun an audit
‹ all tools
Textgitgud / tools

JSON Formatter

Pretty-print, minify and validate JSON. Points at the exact error.

Runs entirely in your browser — nothing you paste is uploaded.

About JSON Formatter

Paste JSON, get it back readable. The formatter re-indents with two spaces, four spaces or a tab, and the minifier collapses it to a single line for the times you need to put a payload in an environment variable or a curl command without it wrapping.

The useful part is the error reporting. `JSON.parse` throws a message that varies by engine and usually gives you a character offset, which is no help in a 4,000-line file. This tool converts that offset into a line and column and shows you the line, so a trailing comma on line 812 is a thing you can find rather than a thing you binary-search for.

Everything happens in the tab. There's no upload step, no server round-trip and no request while you type — which matters, because the JSON people most want to format is usually an API response with a token or a customer record in it. Pasting that into a random online formatter is a habit worth breaking.

For structural work rather than cosmetic, the diff tool has a JSON mode that normalises key order before comparing, and the JSONPath tool queries a document rather than reformatting it.

Frequently asked

›Why does my JSON fail to parse when it looks fine?

The usual three: a trailing comma after the last element, single quotes instead of double quotes, or an unescaped newline inside a string. All three are legal in JavaScript object literals and illegal in JSON, which is why they survive a copy out of a code file.

›Does JSON allow comments?

No. The spec has no comment syntax. Formats that appear to allow them — JSONC, JSON5, tsconfig.json — are supersets parsed by tools that strip comments first. Standard `JSON.parse` will reject them, and so will this.

›What happens to very large numbers?

They lose precision. JSON numbers are parsed into IEEE 754 doubles, so anything above 2^53 is silently rounded — a 64-bit database ID sent as a number will come back wrong. Serialise large integers as strings.

›Is key order preserved?

Yes, this tool preserves the order keys appear in. The JSON specification does not require objects to be ordered, and some parsers reorder them — which is exactly why the diff tool's JSON mode re-serialises both sides canonically before comparing.

›Is my data uploaded?

No. The parse, format and minify all run in your browser. The page makes no network request while you're using it.

Related tools