JSON Formatter and Validator
NewFormat, validate and minify JSON in your browser. Paste minified or messy JSON to pretty-print it with 2 spaces, 4 spaces or tabs, or minify it to a single line. Syntax errors are shown as you type, with the line, column and a plain-language explanation. Numbers and text are kept exactly as written.
How to format JSON
- Paste your JSON into JSON input. It is checked as you type.
- Choose the indentation: 2 spaces, 4 spaces or tabs. Optionally select Sort keys to order object keys alphabetically.
- Select Format JSON to pretty-print it, or Minify JSON to remove all whitespace.
- Copy the result or download it as a
.jsonfile.
After the first click, the result follows your input and settings, so you can keep editing and see the formatted JSON update. Your indentation and Sort keys choices are remembered; your JSON is not saved.
How to find and fix JSON errors
When the JSON is invalid, the tool explains the problem, shows the line and column, and points to the exact character. Select Go to error to jump there in the input. Common errors include:
| Error | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the comma before } or ] |
| Single quotes | {'a': 1} | Use double quotes: {"a": 1} |
| Unquoted property name | {a: 1} | Quote the name: {"a": 1} |
| Missing comma | [1 2] | Separate items with commas: [1, 2] |
| Comments | // note | Remove comments; JSON does not allow them |
| Python or JavaScript values | True, None, undefined | Use true, false or null |
| Leading zeros | {"n": 01} | Write 1, or use a string: "01" |
| Line break in a string | "line 1⏎line 2" | Write \n instead of a real line break |
The validator follows the JSON standard (RFC 8259) strictly: it accepts exactly what JSON.parse accepts, so JSON that passes here also loads in JavaScript, Python and other languages.
Values are kept exactly as written
Many online formatters convert JSON to JavaScript objects and back, which silently changes data:
- large numbers such as IDs lose precision:
12345678901234567890becomes12345678901234567000, 1.0becomes1and1e3becomes1000,- escapes such as
éare rewritten, - duplicate keys disappear.
This formatter only changes whitespace and, if selected, the order of keys. Numbers, strings and duplicate keys stay exactly as you wrote them.
Format JSON in the command line and in code
# jq (Linux, macOS, Windows)
jq . data.json # pretty-print
jq -c . data.json # minify
jq -S . data.json # sort keys
# Python
python -m json.tool data.json
// JavaScript: pretty-print with 2 spaces, or minify
JSON.stringify(JSON.parse(text), null, 2);
JSON.stringify(JSON.parse(text));
Note that JSON.parse and json.tool round very large numbers, unlike this tool.
Frequently asked questions
Is my JSON sent to a server?
No. Formatting and validation run in your browser, and your JSON is never uploaded or saved. It is safe to use for API responses and configuration files that contain private data.
What is the difference between formatting and minifying JSON?
Formatting (pretty-printing) adds line breaks and indentation so people can read the structure. Minifying removes all unnecessary whitespace so the JSON is as small as possible for storage or sending over a network. Both contain exactly the same data.
Does JSON allow comments or trailing commas?
No. Standard JSON allows neither. Some tools accept them in configuration files (JSON5 or JSONC, used by VS Code), but JSON.parse and most APIs reject them, so this validator reports them as errors.
Why does my JSON fail with "Property names must be strings in double quotes"?
JSON requires every key in double quotes, such as {"name": "value"}. JavaScript object syntax like {name: 'value'} is not valid JSON.
How large a JSON file can I format?
Files of several megabytes work well. Very large output is shown without colour highlighting so that the page stays responsive.
Related tools
- JWT encoder and decoder — Decode the JSON header and payload of a JSON Web Token.
- Base64 encoder and decoder — Encode and decode Base64 text.
- UUID generator — Generate UUIDs for IDs in your JSON.
- SHA-256 hash calculator — Calculate a checksum of a JSON file.
Further reading
- RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format
- JSON.org — Introducing JSON
- MDN — JSON.parse()
Last updated: