JSON Formatter & Validator

Paste JSON and choose an action.

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

When developers format JSON

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 containsLikely causeFix
Unexpected token 'Single quotes around a key or stringReplace 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 bracketRemove the comma after the last item
Unexpected end of JSON inputThe text stops early: a missing } or ], or a copy that was cut offCheck the end of the input and count brackets
Unexpected token /A comment such as // noteDelete comments; standard JSON has none
Unexpected token u or Nundefined or NaN, which are JavaScript values, not JSONUse null or a number
Bad control character in stringA real line break or tab inside a stringWrite it as \n or \t

A quick debugging routine

  1. Click Validate only and note the line and column if they are shown.
  2. 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.
  3. Fix one problem and validate again. A single missing quote can cause several confusing errors further down.
  4. 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.