JSON Formatter & Validator
About this tool
Paste JSON to check that it is valid and to reformat it with consistent indentation, or minify it onto a single line. It is handy for reading an API response, a log entry or a config file that arrives as one long line.
The output updates as you type. Everything runs in your browser, so you can paste JSON that contains tokens or personal data without it being uploaded.
Example
Input:
{"user":{"id":7,"name":"Mika","roles":["admin","dev"]},"active":true}
Formatted (2 spaces):
{
"user": {
"id": 7,
"name": "Mika",
"roles": [
"admin",
"dev"
]
},
"active": true
}
What formatting changes
This tool parses your JSON and writes it out again, so the result is equivalent JSON but not always a byte-for-byte copy of your data. In particular:
- Very large integers lose precision. Numbers are parsed as 64-bit floating-point values, so
12345678901234567890becomes12345678901234567000. If you handle IDs of that size, keep them as strings. - Numbers are normalized:
1.0becomes1,1e3becomes1000, and1.50becomes1.5. - Escaped characters are decoded:
"é"is written as"é". - If an object repeats a key, only the last value is kept.
- Keys that look like whole numbers (such as
"1"or"2") are moved to the front in ascending order, as JavaScript objects do. Other keys keep their original order unless you turn on Sort keys.
Common syntax errors
- A trailing comma after the last item, as in
{"a":1,} - Unquoted or single-quoted keys and strings, as in
{a:1}or{'a':1} - Comments, which JSON does not allow
undefined,NaNandInfinity, which are not valid JSON values
FAQ
Q. Is my JSON uploaded anywhere?
A. No. Parsing and formatting happen in your browser. The page does not send what you paste to any server.
Q. The error message shows a position. How do I find it?
A. Current versions of Chrome and Edge report the character position and the line and column where parsing failed. Other browsers word the message differently and may not include a position.
Q. How do I turn JSON into code?
A. Use JSON to PHP Array to get a PHP array definition.