JSON formatter and validator
Format, minify and validate JSON, with the exact line and column of any error.
Code examples
Copy and paste these into your own project. Each one uses only the language's standard library, so there is nothing to install.
const text = '{"b":1,"a":[1,2]}'
console.log(JSON.stringify(JSON.parse(text), null, 2))What it does
Format, minify and check JSON, with errors that point at the exact line and column. It can also sort keys and repair common mistakes such as trailing commas, comments and single quotes. Everything runs in your browser, so even large or private documents stay on your device.
How to use it
- Paste JSON into the input, or drop a file.
- Choose how to format it: indentation, minified output, key sorting and line endings.
- If the JSON is invalid, read the message under the input. It names the problem and where it is.
- Copy the result or send it to another tool, for example to decode a Base64 field you found inside it.
Examples
Unformatted input:
{ "name": "Ada", "tags": ["math", "code"], "born": 1815 }
Formatted with two spaces:
{
"name": "Ada",
"tags": ["math", "code"],
"born": 1815
}
Good to know
- Standard JSON allows no comments, trailing commas or single quotes. The repair option fixes them for you.
- Sorting keys makes two documents easy to compare.
- Numbers keep the digits you typed; very large numbers are not rounded when you only format.
What is JSON?
JSON is a plain-text format for structured data: objects, arrays, strings, numbers, true, false and null. It is the default way web services exchange data. This tool checks that your text is valid JSON and lays it out so it is easy to read.
Frequently asked questions
Why is my JSON invalid?
The most common causes are a trailing comma, single quotes instead of double quotes, unquoted keys and comments. JSON allows none of these.
Does formatting change my numbers?
No. Numbers and strings are copied exactly as you wrote them, so very large numbers keep every digit.
Is my JSON sent anywhere?
No. Everything runs in your browser and nothing is uploaded.