JSON Formatter & Validator

Paste JSON to format it, check that it is valid, or minify it. When it is broken you get the exact line and column, with a pointer to the problem.

FreeNo sign-upRuns in your browser: your data is not uploaded

The JSON errors you will meet most

  • Trailing comma: {"a": 1, "b": 2,}. JavaScript allows it, JSON does not. Remove the last comma.
  • Single quotes: {'a': 1}. Keys and strings must use double quotes.
  • Unquoted keys: {a: 1} is a JavaScript object, not JSON.
  • Comments: // note or /* note */ are not allowed in JSON. Remove them, or use JSONC or JSON5 where a tool supports it.
  • Special values: NaN, Infinity and undefined are not valid. Use null or a string.
  • Unescaped characters: a raw line break or tab inside a string must be written as \n or \t, and a backslash as \\.

Format or minify?

Formatted JSON (with indentation) is for people: reading API responses, config files and logs. Minified JSON removes all spaces and line breaks to save bytes when sending data over the network. The content is the same either way.

Sorting keys

JSON objects have no required key order, but sorting keys A-Z makes two files easy to compare in a diff. Arrays are never reordered, because their order is part of the data.

Working with PHP or Laravel?

To turn JSON into a PHP array for a config file or a test, use the JSON to PHP array converter. In PHP itself, json_decode($text, true) returns an array and json_last_error_msg() tells you why decoding failed.

FAQ

How do I find the error in my JSON?
Paste it above. The tool shows the line and column where parsing stopped and marks the spot. The real mistake is usually just before it, often a missing or extra comma.
Is my JSON sent to a server?
No. Formatting and validation run in your browser, so you can paste API responses or config files safely.
Why is my JSON valid in JavaScript but not here?
JavaScript object syntax allows single quotes, unquoted keys, comments and trailing commas. Strict JSON allows none of those.
What is the difference between format and minify?
Format adds indentation and line breaks for reading. Minify removes all whitespace for the smallest size. The data does not change.

Related guides

Found it useful? Put a link in your docs, README or forum answer so others can use it too:

HTML
<a href="https://headsntail.com/tools/json-formatter">JSON Formatter & Validator</a> (free, by HeadsNTail)
Markdown (GitHub, Stack Overflow, dev.to)
[JSON Formatter & Validator](https://headsntail.com/tools/json-formatter)

Need it done on your server? HeadsNTail sets up Laravel apps, cPanel hosting and migrations for businesses. See services or ask a question.