JSON Formatter & Validator: Fix Errors, Tree View
Format, validate and minify JSON with errors shown by line and column, one-click fixes for trailing commas and quotes, and tree or graph views.
Updated November 2026
Reviewed by Rafael Duarte
How this JSON formatter works
Three steps to the output you need
1. Paste your JSON
Minified, badly indented or already formatted, it's checked as you type. If it's invalid, you see your browser's error message, plus a line and column badge in Chrome, Edge and Firefox.
2. Fix and format
Click Fix to repair common mistakes, then read the Pretty Print output (2 or 4 spaces) or grab the Minify version.
3. Explore the structure
Switch to Tree, Graph or Raw List to see how the data is nested. Every tab updates as you edit.
What this JSON formatter does
Well beyond pretty-printing
Validates as you type
Invalid JSON shows the browser's own parser message. In Chrome, Edge and Firefox it also gets a badge such as L1:17 with the line and column; Safari doesn't report a position.
Repairs broken JSON
The Fix button uses jsonrepair to handle trailing commas, single quotes, unquoted keys, comments and missing closing brackets.
Tree, graph and path list views
A collapsible Tree, a Graph of node cards (up to 6 levels and 20 children per node) and a Raw List of every path, searchable with Ctrl+F.
Quick CSV export
Export CSV turns an array of objects into a comma-separated file, with headers taken from the keys.
Minifies
Strips all whitespace to shrink the payload before embedding it in code.
Saves snippets
Up to 20 named snippets persist in localStorage between sessions.
Examples
L1:17 badge (the trailing comma)When you'll reach for a JSON formatter
The most common scenarios people use this for
Debugging an API response
Paste the raw body from the Network tab or Postman to read it with syntax highlighting.
Validating config before a commit
Paste package.json or any JSON config to catch syntax errors such as trailing commas before you push. To check the structure itself (required fields, types), use the JSON Schema Validator.
Quick CSV export
Turn a simple array of objects into a comma-separated file. For CSV that opens cleanly in Excel, use the CSV to JSON Converter.
Minifying for production
Strip whitespace before embedding the payload in an HTTP request.
Exploring unfamiliar data
The tree and graph views make it fast to understand the shape of a large, deeply nested JSON payload.
Invalid JSON? Start here
Trailing comma
Valid in JavaScript, forbidden in JSON (RFC 8259). {"name": "Alice",} fails. Remove the comma or click Fix.
Single quotes
JSON requires double quotes for keys and string values, so {'name': 'Alice'} is invalid.
Unquoted key
{name: "Alice"} is valid JavaScript, but JSON requires {"name": "Alice"}.
Comments in JSON
JSON doesn't support // or /* */. Fix strips them; if you need comments to stay, use JSONC, YAML or TOML. More examples in How to Validate JSON and Find Syntax Errors.
Why format your JSON here
Minified JSON is efficient to transfer but hard for people to read. Formatting makes the structure visible at a glance: which keys live inside which objects, and how many items each array holds.
The Fix button, the collapsible tree, the graph and the path list cover the usual debugging steps in one place. Everything runs in your browser, and up to 20 named snippets can be saved in localStorage for later.
Frequently asked questions
Yes, it checks the syntax as you type. An error banner shows your browser's parser message and, in Chrome, Edge and Firefox, a line and column badge such as L1:17. To validate the structure against a schema, use the JSON Schema Validator.
Paste it and click Fix. It uses the jsonrepair library to remove trailing commas and comments, turn single quotes into double quotes, quote bare keys and close missing brackets. If the input is too broken to repair, the text stays as it was and the error banner tells you where parsing stopped.
Open the Tree tab for a collapsible view with zoom, or Graph for node cards laid out horizontally or vertically. Raw List shows every path, such as features[0].name, with a search box.
For a quick file, click Export CSV in the Pretty Print tab. For CSV that opens cleanly in Excel, with a choice of delimiter, use the CSV to JSON Converter, which also converts JSON to CSV.
A comma after the last item is valid in JavaScript but forbidden by the JSON spec (RFC 8259). Click Fix to remove it automatically, or delete the comma by hand.
No, neither // nor /* */ is allowed. For readable annotations, use JSONC (supported by VS Code), YAML, or TOML instead. Paste JSONC here and Fix will strip the comments.
Formatting adds indentation and line breaks so people can read the structure. Minifying removes them to cut transfer size. Neither one changes your data: keys and string values come out exactly as you pasted them.
It works, but everything is parsed and highlighted in your browser on every edit, so payloads of several hundred KB can feel sluggish. The Raw List shows the first 500 paths and the Graph stops at 6 levels. For files in the megabyte range, a desktop editor or jq is a better fit.
References
Related Tools
- CSV to JSON Converter & JSON to CSV Online Developer Paste or upload a CSV (comma, semicolon, tab or pipe) and get clean JSON. Also converts JSON to CSV that Excel opens without garbled characters.
- SQL Formatter & Beautifier: Format SQL Queries Online Developer Paste a SQL query to get it indented, with uppercase keywords and one clause per line, or minify it. Works with MySQL, PostgreSQL and SQL Server syntax.
- XML Formatter & Validator: Pretty Print, Tree, XPath Developer Paste XML to pretty print or minify it, spot the line with the error, browse it as a tree, run XPath queries, diff two files or convert to JSON.
- JSON Schema Validator Online: Draft-07, 2019-09, 2020-12 Developer Paste JSON and a schema to see every error with its exact path as you type. Supports Draft-07, 2019-09 and 2020-12 via Ajv, with no upload.
- YAML to JSON Converter & JSON to YAML Online Developer Paste YAML from docker-compose, Kubernetes or GitHub Actions and get JSON instantly, with anchors expanded and multi-document files (---) as an array.