JSON Formatter & Validator
Beautify or minify JSON, sort keys, and see exactly where invalid JSON breaks — all in your browser.
Drop a .json file here
or click to browse — read locally, max 20 MB
✓ Valid JSON21 valuesdepth 4281 B → 469 B
Formatted JSON27 lines
{
"order": {
"id": "A-1001",
"created": "2026-03-14T09:30:00Z",
"total": 59.90,
"items": [
{
"sku": "KB-01",
"name": "Keyboard",
"qty": 1,
"price": 49.90
},
{
"sku": "CB-02",
"name": "USB-C cable",
"qty": 2,
"price": 5.00
}
],
"customer": {
"name": "Ada Lovelace",
"email": "ada@example.com",
"vip": true,
"notes": null
}
}
}Need to explore a large document instead of reformatting it? Open it in the JSON Viewer to collapse branches, search keys and copy JSONPaths.
What this JSON formatter does
APIs, log files and build tools usually emit JSON on a single line to save bytes. That is great for machines and useless for a person trying to read a 4 KB response or review a configuration change. This tool rewrites JSON with consistent indentation (or strips all whitespace for the smallest possible payload), and it checks the text against the strict JSON standard (RFC 8259) while doing so.
It is a text-in, text-out tool: you get back a JSON document you can paste into a file, a pull request or a test fixture. If you would rather browse a big document without reformatting it — collapse branches, search for a key, copy the path to a value — use the JSON Viewer instead.
How to use it
- Paste JSON into the JSON input box, drop a
.jsonfile on the upload area, or click Load example. - Choose Beautify or Minify under Output.
- For beautified output, pick the Indentation: 2 spaces, 4 spaces or Tab.
- Optionally tick Sort keys alphabetically to get a stable key order, which makes two documents much easier to compare.
- Read the status line: a green Valid JSON with value count and size, or a red box pointing at the error.
- Use Copy or Download .json to take the result with you. The output updates as you type.
Worked example
Input (minified, as an API would return it):
{"order":{"id":"A-1001","total":19.90,"items":[{"sku":"X1","qty":2}]},"paid":true}Output with Beautify, 2 spaces and Sort keys alphabetically enabled:
{
"order": {
"id": "A-1001",
"items": [
{
"qty": 2,
"sku": "X1"
}
],
"total": 19.90
},
"paid": true
}Notice that 19.90 is kept as written. A formatter built on JSON.parse + JSON.stringify would print 19.9, and would turn an ID like 12345678901234567890 into 12345678901234567000. Switching to Minify gives back the original one-line text (82 characters).
Now an invalid document (the Try invalid JSON button loads a similar one):
{
"a": 1,
"b": [1, 2,],
}The tool reports:
Invalid JSON — line 3, column 14 Trailing comma before ']' is not allowed in JSON. 2 | "a": 1, 3 | "b": [1, 2,], | ^ 4 | }
Remove that comma and the next error (the comma before the closing brace) is reported the same way.
Options and what the result means
- Beautify puts every property and array item on its own line. Empty objects and arrays stay compact as
{}and[]. - Minify removes every insignificant space and line break. Whitespace inside strings is never touched.
- Sort keys alphabetically sorts object properties recursively by plain character comparison; arrays keep their order.
- Values in the status line counts every object, array, string, number, boolean and null; depth is the deepest nesting level; the sizes are UTF-8 bytes before and after.
- Duplicate keys are listed with their path (for example
$.user.id) because most parsers drop all but the last occurrence.
Limitations
- Only strict JSON is accepted. JSON5, JSONC (comments), trailing commas and NDJSON (one document per line) are reported as errors rather than converted.
- The tool reports the first error it finds; fix it and the next one, if any, appears.
- Inputs up to 20 MB are accepted. Syntax colouring switches off for outputs over 200,000 characters, and very large files can make the text box slow in some browsers.
- Nesting deeper than 1,000 levels is rejected.
Tips and common mistakes
- Copying an object literal from JavaScript code usually fails because of single quotes and unquoted keys — the error message names both.
- Sort keys on both versions before comparing two configs, or use JSON Diff to compare them structurally.
- Commit formatted JSON with the same indentation your editor or Prettier uses, otherwise every line shows up in the diff.
- Minified JSON is smaller to send, but gzip already removes most of the whitespace overhead on the wire; minify mainly matters for storage and embedding.
Frequently Asked Questions
Is my JSON sent to your servers?
No. Parsing, validation and formatting run in JavaScript inside your browser tab. Pasted text and uploaded files are never uploaded, logged or stored.
Does formatting change my data?
No. Only whitespace changes. Numbers and strings are written exactly as they appear in your input, so large integers such as 12345678901234567890 and escapes such as \u00e9 are not rewritten. The only optional change is key order, when you tick Sort keys alphabetically.
How do I find the error in invalid JSON?
The tool shows the line and column of the first error, a plain-English explanation and the surrounding lines with a caret under the problem. Typical causes are trailing commas, single quotes, unquoted property names, comments and values like undefined or NaN.
Should I indent with 2 spaces, 4 spaces or tabs?
It is a team convention, not a rule of JSON. 2 spaces is the default of Prettier and npm's package.json, 4 spaces matches Python's json.dumps(indent=4), and tabs let each editor choose the display width.
What does Sort keys alphabetically do?
It reorders the properties of every object, at every depth, by comparing key names character by character (uppercase letters sort before lowercase). Array order is never changed, because in JSON array order is meaningful.
Why does the tool warn about duplicate keys?
JSON technically allows the same key twice in one object, but most parsers, including JavaScript's JSON.parse, silently keep only the last value. The formatter keeps both copies and lists their paths so you can decide which one is correct.
Related tools
- JSON ViewerView, validate and explore JSON with syntax highlighting and interactive tree view
- CSV ↔ JSON ConverterConvert between CSV and JSON formats
- Excel to JSON ConverterConvert Excel, ODS or CSV sheets to JSON — or JSON arrays back to .xlsx. Choose sheet, header row, date and empty-cell handling. 100% client-side.
- JSON to TypeScriptGenerate TypeScript interfaces from JSON objects
- XML ViewerValidate, format, and explore XML documents with an interactive collapsible tree view. Supports .xml, .xsd, .svg, .rss, .plist and any XML-based format. Runs entirely in your browser.
- JSON DiffCompare two JSON objects and visually highlight added, removed, and changed properties side by side.
Found a bug or a wrong result? Report it.