Paste a config file, an API response, or a one-line blob into the box above. Format pretty-prints it, Minify collapses it, and the validator flags trailing commas and other syntax errors with a line and column. This JSON formatter is part of the programming tools on TechOpt.io — next to the UUID generator.
How this JSON formatter pretty-prints vs minifies
Format adds newlines and indentation so you can read nested objects, following RFC 8259 JSON. Pick 2 spaces, 4 spaces, or a tab — 2 spaces is the usual default in JavaScript and most APIs. Minify strips that whitespace so the payload is as small as a single line, which is what you want in logs, environment variables, and some request bodies.
JSON vs a JavaScript object
JSON looks like a JavaScript object or array, but it is stricter. Keys must be double-quoted strings. Strings use double quotes, not single quotes. There are no comments, no trailing commas, and no undefined. Values are objects, arrays, strings, numbers, true, false, or null. If you paste a JS object literal with unquoted keys, this validator will reject it — that is correct JSON, not a bug in the parser.
Common parse errors
| What you pasted | Why it fails | Fix |
|---|---|---|
Trailing comma: {"a": 1,} | JSON does not allow a comma after the last property or array item. | Remove the last comma. |
Single quotes: {'a': 1} | Strings and keys must use double quotes. | Replace ' with ". |
Comments: {"a": 1} // note | Plain JSON has no // or /* */. | Delete the comment, or use JSONC only in tools that accept it. |
Unquoted keys: {a: 1} | That is a JavaScript object, not JSON. | Quote the key: {"a": 1}. |
The status box reports the first error the parser hits, with a line and column so you can jump to it. Fix that, then format again — later errors only show up after the first one is gone.
Sort keys
Turn on Sort keys before Format or Minify to rewrite every object in alphabetical key order, nested objects included. Arrays keep their item order. That is useful when you are diffing two configs and do not care about the original property order.
Format JSON in code
The box above is for a quick copy. In a terminal or app, use the language you already have:
echo '{"a":1}' | jq .
echo '{"a":1}' | python3 -m json.tool
JSON.stringify(JSON.parse(text), null, 2); // pretty-print in JavaScript
JSON.stringify(JSON.parse(text)); // minify
FAQ
How do I pretty-print JSON?
Paste it into the box and click Format. Choose 2 spaces, 4 spaces, or a tab for the indent. Invalid JSON is left as-is and the status box shows the first syntax error.
Why is my JSON invalid?
The usual causes are a trailing comma, single quotes, comments, or unquoted keys. JSON is stricter than JavaScript object literals. The validator reports the first error with a line and column so you can fix that spot and try again.
What is the difference between format and minify?
Format pretty-prints with indentation so nested objects are readable. Minify removes unnecessary whitespace so the value fits on one line. Both keep the same data; only the spacing changes.
Can I sort object keys?
Yes. Enable Sort keys, then Format or Minify. Every object is rewritten with keys in alphabetical order, including nested objects. Array item order is unchanged.
Does this JSON formatter upload my data?
No. It runs entirely in your browser. Pasted JSON never leaves your machine.
How do I format JSON in a terminal?
Pipe it through jq (jq .) or Python’s json module (python3 -m json.tool). In JavaScript, JSON.stringify(JSON.parse(text), null, 2) pretty-prints and JSON.stringify(JSON.parse(text)) minifies.
Looking for more developer how-tos? Browse the programming guides or the rest of the tools.