JSON Formatter & Validator

Pretty-print messy JSON, explore it as a collapsible tree, fix common errors in one click, or convert it to XML, CSV or YAML. Validated locally — your data never leaves your computer.

1 Paste your JSON — or upload a file, or load the sample

More tools: sort, upload, indent

Minify ignores this — it removes all whitespace.

2 View, convert & download — text or tree, your call

Converts the last valid result — the converted text appears above, ready to copy or download.

What is a JSON formatter?

JSON — JavaScript Object Notation — is the plain-text format nearly every API, config file and web service uses to move structured data around. A JSON document is just nested objects ({"key": "value"}), arrays ([1, 2, 3]), strings, numbers, booleans and null. It is simple by design, and it is also brutally unforgiving: one missing comma, one trailing comma, one single quote where a double quote belongs, and the whole document is rejected.

A formatter takes a compressed or messy JSON document and reprints it with consistent indentation, one value per line, so a human can actually read it. A validator checks whether the document follows the rules at all, and — the useful part — tells you exactly where it breaks. A minifier does the reverse: it strips every space and line break so the document is as small as possible for sending over a network.

This tool does all three in your browser. Paste the JSON, click Format, and the result appears with two-space indentation. Click Validate and it reports valid or gives you the line and column of the first error. Nothing is uploaded: API keys and personal data in your JSON stay on your computer, which matters more than it sounds — people paste live API responses containing real tokens into online formatters every day.

How to format and validate JSON

  1. Paste the JSON into the box. It can be minified, half-formatted, or copied straight from a browser’s network tab. You can also upload a .json file from “More tools” — the file is read in your browser, never uploaded.
  2. Click Format to pretty-print it with your chosen indentation, or Minify to compress it to a single line.
  3. Click Validate if you only want a verdict without changing the text. A valid document reports its type, key count and nesting depth.
  4. Read the error — or let Fix JSON handle it. If the JSON is invalid, the tool shows the line and column of the problem and the offending line of text. Or click Fix JSON: it repairs trailing commas, single quotes, comments and unquoted keys in one pass and tells you what it fixed.
  5. Explore the tree. Switch to the Tree tab to fold the document down to the branch you care about. Expand all and Collapse all sit next to the tab.
  6. Sort, convert or download. Sort keys A–Z or by value from “More tools”; convert the result to XML, CSV or YAML; then copy it or download it as a file.

The most common errors are worth memorising: a trailing comma after the last item in an object or array, single quotes instead of double quotes around strings, an unquoted key, and a missing comma between two values. The error message will point at the character where the parser gave up — the actual mistake is usually the character just before it.

Tree view, repair, sorting and conversion

Formatting is only half the job with a big document. The Tree tab shows the parsed document as a collapsible tree: every object and array folds down to a one-line summary (“4 keys”, “12 items”), so you can hide the ninety percent you do not need and drill into the one branch you care about. Strings, numbers, booleans and null each get their own colour, and the keys stay readable at a glance. On a very large document the tree stops after 5,000 nodes and says so — the Text view still holds the whole document.

Fix JSON is the button for the document that “looks fine” but will not parse. It repairs the five mistakes that cause most failures: trailing commas after the last item, single quotes instead of double quotes, unquoted keys, // and /* */ comments, and raw line breaks inside strings. It works on a string-aware pass, so a comma inside a quoted value is never touched. After the repair it tells you exactly what it fixed — “Fixed: 2 trailing commas, 1 single-quoted string” — and puts the repaired document in the input box, so you can see what changed. If errors remain, the validator shows the next one; fixing is a loop, and each pass gets shorter.

Sorting gives you a canonical version of a document: Sort keys A–Z orders every object’s keys alphabetically, all the way down, which makes two versions of the same config diff cleanly. Sort by value orders entries by their values instead — handy when you want the smallest (or alphabetically first) values on top. Both keep the data identical; only the order changes.

Conversion covers the three formats JSON most often needs to become. XML turns objects into elements (<root><name>…</name></root>), with arrays repeated as sibling elements. CSV turns an array of objects into a table — one column per key, in order of first appearance — or an object into a two-column key/value sheet. YAML turns objects into mappings and arrays into - item lists with two-space indentation, quoting strings only when they would be ambiguous. The converted text appears in the result box, ready to copy or download.

Three everyday uses

1. Debugging an API response

An API returns a 400 error, or your app crashes parsing the response. Copy the response body into the formatter. If it is valid, the formatted version lets you see the structure at a glance — a missing field, a null where you expected an object, a string where you expected a number. If it is invalid, the line and column tell you exactly where the server’s output broke, which is often the bug itself: a hand-built JSON string with a stray comma, or an error page returned with a 200 status.

2. Cleaning up a config file

Config files for editors, build tools, linters and apps are JSON, and they drift: inconsistent indentation, keys in random order, a comment someone added that JSON does not actually support. Paste the file, format it, and you get a clean, canonical version you can save back. The key count and depth in the stats line also tell you at a glance whether a config has grown into something that deserves splitting up.

3. Shrinking data before sending it

Pretty-printed JSON is easy to read and wasteful to send — a 100 KB document can be 60 KB minified. Before embedding JSON in a URL, a request body, or a database field, run it through Minify. The data is identical; only the whitespace is gone. Just remember to keep the formatted copy for yourself, because nobody can read the minified version.

Common mistakes to avoid

  • Trailing commas. {"a": 1,} is invalid JSON, even though JavaScript allows it. The last item in an object or array takes no comma.
  • Single quotes. JSON strings use double quotes only. {'a': 1} is not JSON, however natural it looks to a JavaScript developer.
  • Comments. JSON has no comments. // note or /* note */ inside a document makes it invalid. If your config needs comments, it is probably JSONC or JSON5, not JSON.
  • Unquoted keys. {a: 1} is a JavaScript object literal, not JSON. Keys must be double-quoted strings.
  • Pasting the error page instead of the JSON. If an API returns an HTML error page with a 200 status, the “JSON” you paste starts with <html>. Validate first — the error will say so immediately.

Frequently asked questions

Is this JSON formatter free?
Yes. No account, no limits, no upload. Your JSON never leaves your browser.
Is my data sent to a server?
No. Formatting and validation run entirely in your browser. That matters, because JSON often contains API keys, tokens and personal data. You can test it: load the page, disconnect from the internet, and the tool still works.
What is the difference between Format and Minify?
Format adds indentation and line breaks so a human can read the document. Minify removes all unnecessary whitespace so the document is as small as possible. Both produce the same data; only the layout differs.
Why does the validator say my JSON is invalid when it looks fine?
The usual culprits are a trailing comma, single quotes, a comment, or an unquoted key. Read the line and column in the error message — the problem is at or just before that position.
Can I format JSON with duplicate keys?
The tool will parse it — the parser keeps the last value for a duplicated key — but duplicate keys are a smell. If the same key appears twice, one of the values is silently lost, so fix the source rather than the formatting.
What does Fix JSON repair?
Fix JSON repairs the five most common mistakes in one click: trailing commas, single quotes instead of double quotes, unquoted keys, // and /* */ comments, and raw line breaks inside strings. It tells you exactly what it fixed, and if the document still has errors after that, the validator shows the next one.
What is the tree view for?
The Tree tab shows the parsed document as a collapsible tree, so you can fold away the parts you do not need and drill into the one branch you care about. Expand all and Collapse all are next to the tab. It works on JSON; converted XML, CSV and YAML stay in the Text view.
Can I convert JSON to XML, CSV or YAML?
Yes. After the JSON validates, click XML, CSV or YAML under the result. An array of objects becomes a CSV table with one column per key; objects become XML elements or YAML mappings. The converted text appears in the result box, ready to copy or download.

Privacy

JSON is where secrets live: API keys, session tokens, database credentials, personal records. Pasting those into a server-side formatter sends them to a stranger’s log file. This tool parses everything locally, so your data stays on your machine. Close the tab and it is gone.

Worked example: fixing a real broken JSON document

Here is a document very much like the ones that arrive in bug reports — it looks right at a glance, and it is invalid in three places. Paste it into the tool and see what the validator says before reading on:

{
  "site": "BBQ Tools",
  "tools": ["compressor", "qr",],
  "free": true,
  'version': 1,
  "limits": { "signup": null }
}

The validator reports an error at the trailing comma after "qr" — the first thing it trips on. Remove that comma and validate again, and the next error appears: the single quotes around 'version'. JSON strings take double quotes only, so 'version' must become "version". Fix that, and the document is valid. Two small edits, and the lesson is that JSON errors come one at a time: the parser stops at the first problem, so fixing is a loop of validate, read the line, fix, repeat — never a single pass. Or skip the loop: Fix JSON repairs both mistakes in this example at once and tells you what it did.

There is a faster way to find these in a large document. Format it first: the formatter fails at the same first error, but the error message gives you the line and column, and the offending line is shown in the message. In a 500-line config file, that line number is the difference between a five-second fix and a twenty-minute hunt. Keep the formatted output after you fix it — it is the canonical version of the document, and diffing it against the original shows exactly what changed.

Share this tool

Copy the link below and paste it anywhere — a chat message, an email, a document. Whoever opens it gets the same free tool, with no account and nothing to install.

Related tools