JSON Formatter
Format, validate, and minify JSON instantly — free, private, and works entirely in your browser.
Off by default. Enable only to inspect a round trip you accept may change numeric digits or range. Keep the original file; this does not preserve precision.
Advanced optionsIndent type · Indent size
Your result
Updates as you type- Status
- Valid JSON
- Keys
- 3
- Minified saving
- 13
Parsed successfully; syntax validity does not guarantee a lossless round trip.
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
Unsafe numeric tokens block output unless you explicitly enable Allow lossy number conversion. This flags numbers beyond the safe integer range, overflow and underflow; it does not make ordinary decimal arithmetic exact or detect duplicate keys.
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.
JSON is parsed and re-serialized in your browser. Tool inputs are not uploaded. Keep the original file and use synthetic data when investigating parsing limits.
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
This formatter checks JSON syntax before generating formatted and minified versions. Syntax validity does not establish that values survive a round trip. Unsafe numbers block output by default; explicitly enabling Allow lossy number conversion lets you inspect that loss with a visible warning.
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.
Try the downloadable parsing cases
Save parsing-cases.json, then use Import local file above. This synthetic document intentionally includes a duplicate key and unsafe numbers. Output is blocked initially. Inspect the original text, then enable Allow lossy number conversion only to reproduce the changes below. A persistent warning identifies the lossy output.
| Original field | Generated value | What happened |
|---|---|---|
numericId: 9007199254740993 | 9007199254740992 | Integer precision is lost during parsing. |
stringId: "9007199254740993" | Unchanged string | The ID is text, not arithmetic. |
status: "draft", then "published" | "published" | The last duplicate key wins. |
amount: 1e2 | 100 | Number spelling is normalized. |
overflow: 1e400 | null | Parsing produces Infinity; JSON serialization writes null. |
Expect five counted keys after parsing. Downloading the formatted result cannot recover the discarded digits or the first status value. These are implementation checks, not recommendations for API payload design. RFC 8259 describes interoperability risks around duplicate names and numeric precision.
For a two-file exercise, open JSON Diff Checker and follow its downloadable API comparison walkthrough. Keep numeric identifiers as strings if exact digits must survive this JavaScript-based workflow.
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. The tool does not upload or persist your input. Use synthetic or redacted examples when possible and follow your organization’s rules for production data.
What is the difference between formatted and minified?
The two generated outputs serialize the same parsed value with the same options; formatted output adds indentation and minified output omits it. Neither is a lossless copy of the input: parsing can round numbers, discard duplicate keys and normalize their spelling. Keep the original file when those details matter.
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. Unsafe numbers block output by default. Explicitly allowing lossy number conversion can round large numbers or turn overflow into null; a warning stays visible. Duplicate object keys still keep the last value, and number spelling, escaping and integer-like key order can change. Keep the original for lossless work.
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.
Put the result to work
- Why JSON formatting can change your data
Reproduce large-number rounding and duplicate-key loss, locate the stage that changed a payload, and choose a safer debugging workflow.
- Compare API responses without hiding a regression
Use downloadable API snapshots to separate request metadata, reordered records and a real price edit, with exact expected results.
- Why decoded Base64 sometimes looks like garbage
Distinguish valid encoding from UTF-8 text, recover original bytes and troubleshoot a damaged payload using reproducible local examples.