JSON Formatter
Paste JSON to pretty-print it instantly with the indentation you prefer, or minify it to a single line. Syntax errors are reported with the exact line and column and a caret under the problem, and a collapsible tree view makes large API responses easy to explore. Large numbers are kept exactly as written instead of being rounded.
How to use the JSON Formatter
- Paste or type JSON into the input box, or press Load example.
- Choose 2 spaces, 4 spaces, Tab or Minify.
- Tick Sort keys A–Z if you want keys in alphabetical order.
- Switch to Tree view to expand and collapse nested objects.
- Copy the result or download it as a .json file.
Features
- Beautify with 2/4-space or tab indentation, or minify
- Optional recursive alphabetical key sorting
- Error messages with line, column and a caret marker
- Collapsible, colour-coded tree view
- Duplicate-key warnings and size statistics
- Preserves big integers and number formatting exactly
Benefits
- Read minified API responses and config files at a glance
- Find the exact character that breaks a JSON document
- Your data stays in the browser — nothing is uploaded
Frequently asked questions
Why does my JSON fail with "Trailing comma is not allowed"?
Standard JSON (RFC 8259) does not allow a comma after the last item in an object or array. Remove that comma and the document will parse.
Will formatting change my numbers?
No. Numbers are copied exactly as written, so values such as 12345678901234567890 or 1.50 are not rounded or reformatted as they would be with JSON.parse.
Does it accept comments or single quotes?
No. Comments, single-quoted strings and unquoted keys are JavaScript features, not JSON. The formatter points to them so you can fix the document.
What does Sort keys do to arrays?
Only object keys are sorted, at every nesting level. The order of array items is never changed because it is meaningful.
Related tools
- JSON Validator — Check JSON syntax as you type, see the exact line and column of any error and get warnings for duplicate keys.
- XML Formatter — Pretty-print or minify XML with comments, CDATA and DOCTYPE support, plus a well-formedness check with error positions.
- HTML Formatter — Beautify HTML with your choice of indentation and line wrapping, including inline <script> and <style> blocks.
- CSS Formatter — Beautify minified CSS into readable rules with custom indentation, brace style and one selector per line.
- JavaScript Formatter — Beautify JavaScript with configurable indentation, brace style and line wrapping to make minified code readable.
- Code Minifier — Minify JavaScript with Terser, plus CSS and HTML, and see the original size, minified size and percentage saved.