JSON Formatter
Format, validate, and minify JSON instantly — free, private, and works entirely in your browser.
Advanced options
Your result
Updates as you type- Status
- Valid JSON
- Keys
- 3
- Minified saving
- 13
Parsed successfully in your browser.
Counted through every nested object.
Characters whitespace removal saves.
Formatted
{ "name": "UToolios", "tools": 3, "free": true }
Minified
{"name":"UToolios","tools":3,"free":true}Method, assumptions, and tips
Import JSON locally, inspect syntax-highlighted text or a bounded tree view, and export .json. Long or deeply nested trees use text view for the full document.
Input must be valid JSON — a syntax error is flagged with a line and column when your browser reports one.
Object key order follows JavaScript enumeration rules; integer-like keys may move even when "Sort keys" is disabled.
Minified output removes all non-essential whitespace.
"Escape HTML characters" replaces <, >, and & so the output is safe to embed in an HTML <script> tag.
Your JSON is parsed and re-serialized entirely in your browser — nothing is sent to a server, so even sensitive data stays private.
Use the minified output for anything you send over the network, and the formatted output for anything a person has to read.
Inspecting an API response, spotting a syntax error in a config file, or shrinking a payload before shipping it.
How it works
Format and validate JSON in one pass
Formatting and validating JSON are the same operation. To pretty-print a document you have to parse it first, and anything that parses is valid by definition. So pasting JSON here answers both questions at once: it either reformats, or it tells you where the syntax breaks.
The tool produces two outputs from one input — a formatted version for reading and a minified version for shipping — plus a count of every key, including nested ones.
Why JSON rejects things that look fine
JSON is a far stricter subset of JavaScript object syntax than most people expect. These are all invalid, and all common:
- Trailing commas.
{"a": 1,}is valid JavaScript and invalid JSON. - Single quotes. Strings and keys must use double quotes.
- Unquoted keys.
{a: 1}is a JavaScript object literal, not JSON. - Comments. There is no comment syntax in JSON at all.
- `undefined`, `NaN`, `Infinity`. None are JSON values.
- Leading zeros or a bare leading decimal point in numbers.
If a document came out of a code editor rather than a serialiser, one of these is almost always the cause.
Formatted or minified — use both
They serve opposite purposes, and the difference is pure whitespace:
| Output | Use it for |
|---|---|
| Formatted | Reading, code review, diffing in version control, filing a bug |
| Minified | API payloads, storage, anywhere bytes over the wire cost something |
Both outputs come from the same parsed JavaScript value. They agree with each other, but parsing and re-serialisation can change the original document: see the limits below.
Sorting keys
Sorting keys alphabetically is off by default because JSON objects are unordered by specification, and reordering can obscure the structure an author intended. Turn it on when you are diffing two documents: two API responses containing identical data in different key orders produce an enormous, useless diff until both sides are sorted, at which point the real difference stands out immediately.
Escaping HTML characters
This option replaces <, > and & with their unicode escapes. It matters in one specific situation: embedding JSON inside an HTML script tag. A string containing a closing script tag will otherwise terminate it early and break the page — or worse, become an injection vector. The escapes preserve the parsed string values while preventing these characters from being interpreted as HTML markup.
What parsing can change
This tool uses JSON.parse and JSON.stringify, rather than a lossless text formatter. Keep the original when exact numeric values, key order or spelling matter.
| Input | Minified output | Why |
|---|---|---|
{"id":9007199254740993} | {"id":9007199254740992} | JavaScript numbers cannot represent every integer beyond the safe-integer range. Store opaque IDs as strings. |
{"a":1,"a":2} | {"a":2} | Parsing keeps the last duplicate object key. |
{"n":1e2} | {"n":100} | Re-serialisation normalises number spelling. |
{"2":"b","1":"a"} | {"1":"a","2":"b"} | Integer-like keys follow JavaScript enumeration order. |
A syntactically valid JSON number can also exceed the finite JavaScript range: 1e400 parses as Infinity and serialises as null. Syntax validation does not validate a business schema or guarantee lossless numeric conversion.
RFC 8259, sections 4 and 6 describes duplicate-name interoperability and numeric precision limits. The examples above describe this tool’s actual browser parsing behavior.
Working with sensitive data
Everything runs in your browser. Your JSON is parsed by the browser's own engine and re-serialised locally — it is never uploaded, logged or stored. That matters more than it sounds: API responses routinely contain access tokens, email addresses, internal IDs and customer records, and pasting them into a server-side formatter means handing all of it to whoever runs that server.
If you regularly debug production payloads, that difference is the whole reason to use a client-side tool.
Worked example: inspect an API response before comparing it
Suppose a service returns this compact synthetic response:
{"order":{"id":"9007199254740993","total":19.5,"items":[{"sku":"demo-1","qty":2}]},"ok":true}Load “API response with a string ID” above. With two-space indentation and sorting disabled, expect seven object keys: order, ok, id, total, items, sku and qty. Array positions are not keys in this count. The ID remains "9007199254740993" because it is a string. The formatted and minified outputs parse to the same data.
Inspect the tree to locate order.items[0].qty, then download formatted JSON if you need a readable fixture. To compare a second response, open JSON Diff Checker and paste the two versions there. The link does not transfer the current document or put its values in a URL.
A valid document can still break your API
Changing "qty":2 to "qty":"2" is valid JSON, but changes the value’s type. Deleting order.id also leaves valid syntax. The green status only means the parser accepted the document; it does not check required fields, types, totals or API contracts. Use your application’s schema validation and integration tests for those checks.
Keep the original file when investigating duplicate keys, number precision or signatures over serialized content. A formatter that parses and re-serializes data cannot preserve those textual details. The limitations table above shows concrete cases where its output differs from the original.
FAQ
Can I import, search and explore a JSON file?
Import a local JSON file up to 200 KB, use the highlighted text or tree view, search the output, and download .json. For located syntax errors, Go to error focuses the offending input character. Files never leave your browser.
Why does it say my JSON is invalid?
JSON is stricter than JavaScript object syntax. The usual causes are trailing commas, single quotes instead of double quotes, unquoted keys, or comments — all valid in JavaScript and none valid in JSON. The error message includes a line and column when your browser's JSON engine reports one, so you can jump straight to the problem.
Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser using its own JSON engine. Your data is never uploaded, logged or stored, so it is safe to paste production API responses.
What is the difference between formatted and minified?
Only whitespace. Formatted output is indented for reading, reviewing and diffing; minified output strips every non-essential character to reduce payload size. Both contain exactly the same data.
When should I sort keys?
When diffing two documents. JSON objects are unordered, so two responses with identical data in different key orders produce a huge and useless diff — sorting both sides first makes the real differences visible. Leave it off otherwise.
What does escaping HTML characters do?
It replaces <, > and & with unicode escapes so the JSON is safe to embed inside an HTML script tag. Without it, a string containing a closing script tag would terminate it early and break the page or open an injection risk.
Does formatting change my data?
It can. Parsing uses JavaScript numbers, so large integers may round and numbers outside the finite range can become null. Duplicate object keys keep the last value; number spelling, string escaping and integer-like key order can change. Keep the original when you need a lossless representation.
Does the formatted output have line numbers?
Yes. The formatted panel shows a line-number gutter, matching how a code editor displays JSON, so you can find a specific line quickly or match it against the line the error message points to.