JSON Formatter & Validator
How to use the JSON Formatter & Validator
Paste JSON into the box and click Format to add readable indentation, Minify to remove all unnecessary whitespace, or Validate only to check it without changing it. If the JSON is invalid, the tool shows the parser’s error message and, where the browser provides it, the line and column to look at. Your data is parsed locally and never sent to a server.
Example: formatting a one-line API response
Input: {"name":"Freetoolza","tools":[1,2,3]}. After formatting with two spaces, each key and array item appears on its own indented line, which makes nested data easy to scan. Minifying reverses this to a single compact line, useful for smaller payloads.
Common JSON mistakes
- Trailing commas after the last item in an object or array
- Single quotes instead of double quotes around keys and strings
- Unquoted keys such as
{name: "x"} - Comments, which standard JSON does not allow
- Missing commas between items or unclosed brackets
When developers format JSON
- Reading API responses and log output
- Debugging configuration files
- Checking JSON before sending it to an API
- Reducing the size of JSON by minifying
Frequently asked questions
Is my JSON uploaded?
No. Parsing and formatting use your browser’s built-in JSON support.
Does formatting change my data?
Only whitespace changes. One exception: very large numbers can lose precision because JavaScript stores numbers as 64-bit floats, and duplicate keys keep only the last value.
Can it fix invalid JSON automatically?
No. It reports the problem so you can fix it yourself.
What the error messages mean
The validator shows your browser’s own parser message, and each browser words it slightly differently. These are the messages you will see most often and what usually causes them.
| Message contains | Likely cause | Fix |
|---|---|---|
Unexpected token ' | Single quotes around a key or string | Replace with double quotes |
Expected property name or } | Unquoted key, or a trailing comma before } | Quote the key, or remove the last comma |
Unexpected token ] or } | Trailing comma before a closing bracket | Remove the comma after the last item |
| Unexpected end of JSON input | The text stops early: a missing } or ], or a copy that was cut off | Check the end of the input and count brackets |
Unexpected token / | A comment such as // note | Delete comments; standard JSON has none |
Unexpected token u or N | undefined or NaN, which are JavaScript values, not JSON | Use null or a number |
| Bad control character in string | A real line break or tab inside a string | Write it as \n or \t |
A quick debugging routine
- Click Validate only and note the line and column if they are shown.
- Look at the character just before that position as well as at it; the real mistake is often one step earlier, such as a missing comma at the end of the previous line.
- Fix one problem and validate again. A single missing quote can cause several confusing errors further down.
- Once valid, click Format so the structure is easy to check by eye.
JSON is not the same as a JavaScript object
Code copied from a JavaScript file often looks like JSON but is not: it may use single quotes, unquoted keys, trailing commas, comments or functions, all of which JavaScript allows and JSON rejects. If you are copying from code, expect to make these changes before an API will accept it.
For a step-by-step walkthrough with before-and-after examples, read how to format and validate JSON and fix the most common errors.
Limitations
Very large inputs may slow down your browser. Error positions depend on your browser and may be approximate. Avoid pasting secrets such as API keys into any website. See our Disclaimer and Privacy Policy. Browse the full tools directory. Related tools: JSON Template Creator, URL Encoder & Decoder.
Learn more: read our Developer Guides, articles on JSON, REST APIs and URL encoding.