JSON Formatter
Pretty-print JSON with 2/4-space or tab indentation, optional key sorting, and precise error positions when the JSON is broken. Private, instant, browser-only.
Features
Formatting is lossless: input order is preserved unless “Sort keys” is checked, number formatting follows JavaScript semantics, and indentation can be 2/4 spaces, tabs, or fully compact. When parsing fails you get the exact line and column of the offending character — plus a caret pointing at it in the snippet preview.
How to use JSON Formatter
Paste your JSON and pick an indentation width, then switch between the pretty tree and the compact single line as often as you need. Syntax errors stop formatting at the exact line and column with an excerpt, so the usual suspects — trailing commas, missing quotes — become ten-second fixes.
The formatter doubles as a quick linter: duplicate keys are flagged, and the resulting structure makes nesting depth obvious at a glance. Use it before committing config files, debugging API responses, or preparing payloads to diff against another version.
Frequently asked questions
How does the JSON formatter handle large files?
The parser walks the document efficiently, so files in the megabyte range format in the browser without freezing. Indentation width is selectable, and minify is one click away.
Can I switch between pretty and minified output?
Yes. Format and Minify buttons sit next to each other, so you can flip between a readable tree and a compact single line as often as needed while editing.
Does formatting validate my JSON?
It does. A malformed document stops with the exact line and column of the error, so fixing a missing quote or an extra comma takes seconds.
Are duplicate keys preserved?
JavaScript engines keep the last value for duplicate keys. The formatter flags suspicious duplicates so you can decide whether the document is what you intended.