Input JSON
Output
🧩 How the JSON Formatter Works
JSON formatting is pure text transformation using the browser's built-in JSON parser — the same engine that powers JavaScript itself.
parsed = JSON.parse(rawInput) // validate & parse
pretty = JSON.stringify(parsed, null, 2) // re-serialize with indentation
minified = JSON.stringify(parsed) // serialize without whitespace
1
Validation:
JSON.parse() throws a SyntaxError if the input is malformed. The tool catches this and highlights the error message — pointing to the exact problem.2
Pretty Print:
JSON.stringify(obj, null, 2) serialises the parsed object back to a string with 2-space indentation, producing human-readable output.3
Minify:
JSON.stringify(obj) with no indent argument strips all whitespace — ideal for reducing payload size in APIs.
Why parse then stringify? Because
JSON.parse → JSON.stringify also normalises key ordering and removes trailing commas, producing spec-compliant JSON regardless of the input's quirks.
Processing is 100% client-side. Your JSON data never leaves your browser.