This free JSON formatter beautifies, minifies and validates JSON in your browser. It shows the exact line and column of any syntax error and recognizes JSON-LD, so developers, SEOs and analysts can fix broken data and read API responses faster.
- How to use the JSON formatter
- What the JSON formatter does
- The JSON errors you will meet most
- Format versus minify: when to use each
- Using it as a JSON-LD validator first step
- Reading nested JSON and API responses
- FAQ
- Related tools
How to use the JSON formatter
- Paste your JSON into the input box. It can be an API response, a config file, a log entry or a block of JSON-LD.
- Choose an indent: 2 spaces, 4 spaces or a tab. Then click Format to beautify the data into a readable, indented layout.
- Click Minify when you need the smallest version, for example to embed data in a page or save bandwidth.
- If the JSON is broken, read the error. It names the exact line and column, so you can jump straight to the problem and fix it.
- Tick Sort keys if you want properties in alphabetical order, which makes two files easier to compare. Then copy the result or download it as a file.
Parsing and formatting happen in your browser. The JSON is not sent to a server, so you can paste responses that contain customer or internal data.
What the JSON formatter does
Rewrites compact or messy JSON with consistent indentation. Pick 2 spaces, 4 spaces or tabs to match your team's style.
Strips all spaces and line breaks without changing the data, which gives the smallest possible file.
Checks the syntax as you format. A failure shows the line and column of the error rather than a vague message.
Optional alphabetical ordering of object keys, useful before you compare two versions of a file.
Spots schema.org structured data by its @context and offers to open it in the Schema Markup Validator.
One click to copy the output or save it as a file, with nothing uploaded along the way.
The JSON errors you will meet most
JSON looks like JavaScript but is much stricter. Almost every error comes from the same short list. The line and column in the error message point to where the parser gave up, which is usually at or just after the real mistake.
| Mistake | How to fix it |
|---|---|
| Trailing comma after the last item | Remove the comma before the closing brace or bracket. |
| Single quotes around keys or text | Use double quotes everywhere. |
| Unquoted property names | Wrap each key in double quotes. |
| Comments with // or /* */ | Delete them. JSON has no comments. |
| Missing comma between items | Add a comma at the end of the previous line. |
| Unescaped quote or line break in a string | Escape the quote with a backslash and write a line break as \n. |
| Values like undefined, NaN or Infinity | Replace with null, a number or a string. |
The format is defined in RFC 8259. If your data is valid under that spec, the formatter will accept it, and any tool in your stack that follows the spec will too.
Format versus minify: when to use each
Beautified JSON is for people. Minified JSON is for machines. The data is identical, but the whitespace is not.
Here is a tiny worked example. This is the formatted version:
{
"name": "Rank Ray",
"tools": 3
}And this is the minified version of the same data:
{"name":"Rank Ray","tools":3}Use formatted JSON while you write, review and debug, and keep it in version control so diffs are readable. Use minified JSON when it is served to users or stored in bulk, because fewer characters mean smaller responses. On large payloads the whitespace can be a noticeable share of the size, though compression on your server removes most of that gap anyway.
Using it as a JSON-LD validator first step
Structured data is JSON, so a stray comma can break it before Google ever reads it. Google recommends JSON-LD for structured data in its introduction to structured data. If a rich result is not appearing, check the syntax first.
Paste the JSON object itself, not the surrounding script tag, because the tag is HTML and not JSON. The formatter checks syntax and flags the line and column of any break. When it detects a schema.org @context, it offers to open the data in the Schema Markup Validator, which goes further and checks properties against Google's requirements. Think of the two steps as a JSON ld validator pipeline: syntax first, then meaning.
If you do not have JSON-LD yet, build it with the Schema Markup Generator and then run it through here. A formatter will not tell you that a property is missing, only that the text is valid JSON.
Sorting keys changes the order of properties. That is harmless for most data, but keep the original order if a person or tool relies on it, and remember that array order always carries meaning.
Reading nested JSON and API responses
Raw API output is usually one long line. Format it first, then read it from the outside in. Objects use curly braces and hold named properties. Arrays use square brackets and hold ordered lists. Indentation shows which level you are on, so a property that sits three steps in is easy to place.
For SEO work this comes up often. Search Console exports, crawler results and tag manager containers are all JSON. Formatting them makes it simple to find a field, spot a missing value or copy a clean sample into a ticket. When you compare two exports, format both with the same indent and sorted keys so the only differences left are real ones, then run them through the Diff Checker.
Frequently asked questions
How do I format JSON online?
Paste the JSON into the input box, choose 2 spaces, 4 spaces or tab, and click Format. The tool re-indents the data into a readable layout and checks that it is valid at the same time. You can then copy the output or download it as a file.
How do I find an error in my JSON?
Click Format and read the message under the box. It gives the line and column where the parser failed. Look at that spot and the line above it for a missing comma, a trailing comma, single quotes, an unquoted key or an unescaped quote inside a string.
What is the difference between JSON formatting and minifying?
Formatting adds indentation and line breaks so people can read the data. Minifying removes all unnecessary whitespace so the file is as small as possible. Both keep the data identical, so you can switch between them freely without losing anything.
Is JSON the same as JavaScript?
No. JSON is a text format that looks like a JavaScript object but is stricter. It requires double quotes around keys and strings, allows no comments or trailing commas and cannot contain functions, undefined or NaN. A JavaScript object that works in code may still fail as JSON.
Can I validate JSON-LD structured data here?
You can check that JSON-LD is valid JSON, including the line and column of any syntax error. The tool also recognizes schema.org data and offers to open it in the Schema Markup Validator, which checks the properties Google needs for rich results.
Is my JSON uploaded to a server?
No. Formatting, minifying and validating all happen in your browser. Your data never leaves your device and is not stored, so it is safe to paste API responses, configuration files or logs that contain private values. Closing the tab removes the data.
