Calcoid

JSON Formatter

Format, minify, validate, or sort the keys of any JSON in your browser. Pretty-print with 2 or 4 spaces or a tab, strip whitespace to ship smaller payloads, or alphabetize keys for clean diffs. Reports line and column on parse errors.

Format, minify, validate, or sort JSON

Mode
Indent

0 of 1,000,000 characters.

JSON Formatting Modes

ModeInputOutput
Format{"a":1}Indented JSON
Minify{ "a": 1 }{"a":1}
Sort keys{"b":2,"a":1}{"a":1,"b":2}
Validate{"a":1}Valid JSON

Frequently Asked Questions about the JSON Formatter

Which JSON spec does this formatter follow?
The formatter uses the browser's JSON.parse and JSON.stringify implementations for standard JSON syntax. JSON allows objects, arrays, strings, numbers, booleans, and null. It rejects comments, trailing commas, unquoted keys, NaN, and Infinity. Other systems can still impose limits on number range, duplicate keys, size, or Unicode handling.
Why do trailing commas fail?
ECMA-404 forbids them. The grammar for an object reads as { } or { member (, member)* } with no optional comma after the final member, and the same shape applies to arrays. JavaScript object literals tolerate a trailing comma since ES5, which is why JSON written by hand often grows one accidentally. JSON does not, and a strict parser is required to reject it. If you need to keep trailing commas in your config files, use JSON5 or JSONC (see the next answer) and strip them before parsing as strict JSON.
Can I use comments in JSON?
Not in strict JSON. ECMA-404 has no production for // line comments or /* block comments */, and JSON.parse will throw on either. The two common workarounds are JSON5 (a superset that adds comments, trailing commas, single quotes, unquoted keys, and hex literals) and JSONC (JSON with Comments, used by VS Code settings, tsconfig.json, and similar tools, which adds comments and nothing else). Calcoid sticks to strict JSON because the formatter is meant for data interchange. If your input has comments, run it through a JSON5 or JSONC stripper first and then format the cleaned output here.
When should I pretty-print vs minify?
Pretty-print JSON for human review and diffs. Minify it when whitespace size matters in storage or transport. The reduction depends on the document, and compression can make the transfer difference small. Measure representative payloads instead of assuming a fixed percentage.
What is sort-keys mode for?
Sorting keys recursively can make this formatter's output and diffs stable when object insertion order differs. It is not a standardized canonical JSON format and should not replace a protocol's required canonicalization algorithm. Do not reorder content before verifying a signature or hash that was defined over the original bytes.

Related Calculators

More calculators in "Tech"

See all 98 calculators in "Tech"