Free tool
JSON formatter and validator
Free · no sign-up · runs in your browser, nothing is uploaded
Formatted JSON appears here as you type.
How this JSON formatter works
The text is parsed as you type (big inputs after a short pause). Valid JSON is printed again with the indentation you pick: 2 spaces, 4 spaces or tabs, or no whitespace at all in Minify mode. Sort keys orders every object's keys the way jq -S and Python's sort_keys do, which makes two JSON files easy to compare in a diff.
Unlike formatters built on JSON.parse, it never converts your values. Numbers and string escapes are printed exactly as written, so a 19-digit ID or 1.50 comes out unchanged. It also warns about things that are valid but risky: duplicate keys, integers too big for JavaScript, and a whole document that is a string with escaped JSON inside (common in logs), which you can unescape with one click.
Input can come from the clipboard, a dropped or opened .json file, or a public URL (load URL). Big files stay usable: parsing waits for a short pause in typing, the tree shows long arrays 200 items at a time, and the size, key count, depth and value counts update with every change.
The Tree view collapses objects and arrays and shows how many keys or items each one holds. Search finds keys and values, and clicking a row copies its path as JSONPath ($.orders[0].total), with buttons for the JavaScript accessor and JSON Pointer (/orders/0/total). To query a document with JSONPath expressions, use the JSONPath tester.
Common JSON errors and how to fix them
JSON is stricter than the JavaScript it came from. RFC 8259 allows only double-quoted strings, no comments, no trailing commas, and the values true, false and null. These are the mistakes that break most JSON, and all of them are fixed by Repair JSON:
| Error | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the comma after the last item. |
| Single quotes | {'a': 'b'} | Use double quotes for keys and strings. |
| Unquoted key | {a: 1} | Quote the key: {"a": 1}. |
| Comment | {"a": 1} // note | Delete it, or treat the file as JSONC. |
| NaN, Infinity, undefined | {"a": NaN} | Use null, or a string like "NaN". |
| Leading zero | {"zip": 02134} | Numbers cannot start with 0. Use a string: "02134". |
| Raw line break in a string | "line one↵line two" | Write it as \n inside the string. |
| Missing comma | {"a": 1 "b": 2} | Add a comma between the two members. |
| Two root values | {"a":1}{"a":2} | Wrap them in an array, or use JSON Lines (one value per line). |
Repair also handles Python True/False/None (from printing a dict), curly quotes pasted from a document, hex numbers, a JSONP callback(...) wrapper and missing closing brackets at the end of a cut-off response. It lists every change it made, and Undo brings back your input.
Format JSON in code and on the command line
JavaScript: the third argument of JSON.stringify is the indent, a number of spaces (up to 10) or a string such as a tab.
const pretty = JSON.stringify(data, null, 2); const minified = JSON.stringify(data); const fromText = JSON.stringify(JSON.parse(text), null, '\t');
Python: json.dumps takes indent and sort_keys. Pass ensure_ascii=False to keep non-ASCII characters instead of \u00e9 escapes. From a shell, python -m json.tool formats a file.
import json print(json.dumps(data, indent=2, sort_keys=True, ensure_ascii=False)) # shell python -m json.tool data.json python -m json.tool --sort-keys --indent 4 data.json
jq: . pretty-prints, -c minifies, -S sorts keys and --tab or --indent n sets the indentation.
jq . data.json curl -s https://api.example.com/users | jq . jq -c . data.json # minify jq -S --indent 4 . data.json
Go: json.MarshalIndent encodes a value with indentation, and json.Indent reformats JSON bytes you already have.
out, err := json.MarshalIndent(v, "", " ") var buf bytes.Buffer err = json.Indent(&buf, raw, "", " ")
JSON vs JSONC vs JSON5
Config files often use relaxed JSON dialects. Turn on Allow comments (JSONC) above to format them without errors. In that mode comments are kept when formatting; minifying or sorting keys drops them.
| Feature | JSON | JSONC | JSON5 |
|---|---|---|---|
| Comments (// and /* */) | No | Yes | Yes |
| Trailing commas | No | Accepted by VS Code and tsconfig.json | Yes |
| Single-quoted strings | No | No | Yes |
| Unquoted keys | No | No | Yes |
| NaN, Infinity, hex, +1, .5 | No | No | Yes |
| Typical files | API payloads, package.json | tsconfig.json, VS Code settings.json | Some build tool configs |
A JSON parser rejects anything in the JSONC or JSON5 columns. To turn such a file into strict JSON, press Repair JSON. To move between JSON and YAML, use the JSON to YAML converter.
Why big numbers change in some JSON tools
JSON itself puts no limit on numbers, but RFC 8259 notes that software commonly stores them as IEEE 754 double-precision floats, which hold integers exactly only up to 253 - 1 (9007199254740991, Number.MAX_SAFE_INTEGER in JavaScript). Anything larger is rounded by JSON.parse:
JSON.parse('{"id": 1851234567890123456}').id
// 1851234567890123500That is why many APIs send large IDs as strings. This formatter keeps the original digits and flags each number that would be rounded, with its path. In your own code, ask the API for string IDs, or parse with a library that supports BigInt.
More free developer tools
Looking for a full product instead? See API tools on DevHunt.
FAQ
What is a JSON formatter?+
A JSON formatter (or beautifier) takes minified or messy JSON and adds line breaks and indentation so people can read it. It parses the text first, so it also tells you when the JSON is invalid and where. This one also minifies, sorts keys, repairs common mistakes and shows the data as a collapsible tree.
How do I check if my JSON is valid?+
Paste it into the box above. The badge says valid or invalid as you type, and an invalid document shows the line, column and character where parsing stopped, the lines around it, and a hint. In code, JSON.parse in JavaScript or json.loads in Python throw an error for invalid JSON.
Why is my JSON invalid?+
The usual causes are a comma after the last item, single quotes instead of double quotes, keys without quotes, comments, NaN or undefined as values, and a missing comma between two items. All of these are allowed in JavaScript code but not in JSON. Press Repair JSON to fix them in one go and see a list of what changed.
How do I format a JSON file in VS Code?+
Open the file and run Format Document: Shift+Alt+F on Windows, Shift+Option+F on macOS, Ctrl+Shift+I on Linux. For a file with comments, set the language mode to "JSON with Comments" first, or VS Code will mark the comments as errors.
What is the difference between formatting and minifying JSON?+
Formatting adds whitespace to make JSON readable. Minifying removes all whitespace that is not inside a string, which makes the payload smaller for APIs and storage. Both produce the same data: whitespace between tokens has no meaning in JSON.
Can I format JSON from a URL?+
Yes. Press "load URL" above the input and paste a public link, or open this page with ?url= followed by the link. Your browser fetches it directly, so it only works when that server allows cross-origin requests (CORS). If it does not, open the URL in a tab and paste the response.
Is my JSON sent to a server?+
No. Parsing, formatting, repair and the tree view all run in your browser, and nothing is uploaded or logged. The JSON only goes into the page URL if you press "share link", so do not share links to JSON that holds tokens or personal data.
Does this formatter change my numbers?+
No. It prints every number exactly as written, so 12345678901234567890 and 1.50 stay as they are. Many online formatters run JSON.parse, which rounds integers above 9007199254740991 (2^53 - 1) and turns 1.50 into 1.5. This page warns you when a number would be rounded that way.
Sources: RFC 8259 (JSON) · ECMA-404 · JSON5 spec · MDN: JSON.stringify · MDN: Number.MAX_SAFE_INTEGER · Python json · jq manual · Go encoding/json · VS Code: JSON. Checked October 2026.