Learn more
How to use the JSON formatter
- Add your JSON. Paste it, drop a file onto the input box, press Open file, or use Load from a URL.
- Read the result. It is validated as you type. Valid JSON is formatted straight away; invalid JSON shows the exact line and column of the first problem, with a Go to error button.
- Choose the style. Pick 2 spaces, 4 spaces, a tab or compact output, and tick Sort keys A–Z if you want keys in alphabetical order at every level.
- Fix mistakes. Tick Fix common errors to repair typical copy-and-paste problems. A list shows what was changed.
- Explore. Switch to Tree to collapse and expand sections. Select any row to see its path, such as
$.tools[0].name. - Take it with you. Copy or Download the result, or Copy link to share small documents as a link.
Shortcut: press Ctrl/⌘ + Enter in the input box to format. Your indent, sort and fix choices are remembered on this device; your JSON is not.
What "Fix common errors" repairs
- Comments (
// line,/* block */and# line) are removed. - Trailing commas before
]or}are removed, and missing commas between items are added. - Single quotes and curly quotes around strings become straight double quotes.
- Unquoted property names such as
{name: "x"}get quotes. - Literals like
True,FALSEandNULLare lower-cased, andNoneorundefinedbecomenull. - Strings: raw line breaks and tabs inside a string are escaped, and a stray backslash (as in a Windows path) is escaped.
- Numbers: a leading
+, leading zeros,.5and5.are tidied. - Missing closing brackets at the end of the text are added.
- Unusual whitespace, such as non-breaking spaces from web pages, is replaced with normal spaces.
It does not guess. Problems it cannot repair safely, such as NaN, Infinity, hexadecimal numbers, an unclosed string or several documents in a row, are still reported as errors.
JSON syntax rules
JSON (JavaScript Object Notation) is a text format for data, defined by RFC 8259 and ECMA-404. A value is one of:
- an object:
{"name": "value"}, a set of name/value pairs where every name is a string in double quotes; - an array:
[1, 2, 3], an ordered list of values; - a string: text in double quotes, with escapes such as
\n,\"and\u00e9; - a number:
-12.5e3(no leading zeros, no+, noNaNorInfinity); true,falseornull, always in lower case.
Items are separated by commas, with no comma after the last one. JSON has no comments. Whitespace between values is ignored.
Common JSON errors and how to fix them
| Mistake | Wrong | Right |
|---|---|---|
| Trailing comma | [1, 2,] | [1, 2] |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Wrong-case literal | {"ok": True} | {"ok": true} |
| Comment | {"a": 1} // note | {"a": 1} |
| Leading zero | {"n": 007} | {"n": 7} |
| Unescaped backslash | "C:\Users" | "C:\\Users" |
Frequently asked questions
How do I validate JSON?
Paste it into the box. It is checked as you type. If it is valid you see a green check and the formatted result. If not, you get the exact line and column of the first problem, with the offending line and a caret pointing at it.
Why is my JSON invalid?
The usual causes are a trailing comma after the last item, single quotes instead of double quotes, property names without quotes, comments, a missing comma between items, and unescaped line breaks inside strings. Turn on Fix common errors to repair these automatically.
What is the difference between formatting and minifying JSON?
Formatting (also called beautifying or pretty-printing) adds line breaks and indentation so people can read the data. Minifying removes all unnecessary whitespace so the data is as small as possible to send over a network. Both give exactly the same data.
Is my JSON sent to a server?
No. Everything runs in your browser and nothing you paste or open is uploaded. The one exception is Load from a URL, where your browser asks that address for the data directly. Share links contain your JSON in the link itself, so anyone with the link can read it.
Does formatting change my numbers or strings?
No. Numbers and strings are kept exactly as written, so very large integers such as 12345678901234567890 and long decimals keep every digit. Tools built on JavaScript's JSON.parse can silently round them.
Which JSON standard does it follow?
It validates strictly against RFC 8259 and ECMA-404, the current JSON standards. Any value, not only an object or an array, is accepted at the top level. A repeated key is allowed by the standard, so it is shown as a warning rather than an error.
How big a file can I use?
Files up to 10 MB can be opened. Documents over about 300 KB are not re-checked on every keystroke; press Format instead. Very large results are shown without colouring to stay fast.
Why can't I load some URLs?
Browsers only let a page read another site's data if that site allows it (CORS). If it does not, the request is blocked. Open the address in a new tab, copy the JSON, and paste it in.
Can I share a formatted result?
Use Copy link. It stores your JSON, indent and options in the link (up to about 8 KB). For larger documents, download the file instead.