Developer Tools · tool

JSON Formatter

freeno signup

Format, validate, and minify JSON data

436 chars · 28 lines
JSON Viewer
Off by default. Nothing is saved, and nothing is sent anywhere.

Runs entirely in your browser. Nothing you type or upload is sent to us or stored.

Results are for general guidance. Please check anything important before relying on it. Terms of use

How to Use

  1. The page opens on a formatted example. Paste your raw JSON over it (valid JSON is beautified as soon as you paste), or click Open file to load a .json file. Sample brings the example back.
  2. It is checked as you type. If something is wrong, you'll see the line and column, the line itself with a ^ under the problem, and a plain explanation such as a missing or extra comma. Line numbers run down the left, and the line with the problem is marked. The viewer is dimmed until the JSON is valid again. If the only problems are comments or trailing commas (common in config files), click Remove comments and trailing commas to fix them in one go.
  3. Click Beautify (or press Ctrl+Enter) to indent it neatly. Choose 2 spaces, 4 spaces or tabs, and turn on Sort keys to order keys A to Z. Minify (Ctrl+Shift+Enter) squashes it onto one line. Stringify / unescape turns the JSON into one escaped string (to paste into code or a JSON field), or turns an escaped string such as {\"id\":7} back into readable JSON.
  4. Browse the data in the JSON Viewer. Expand all and Collapse all open or close every level.
  5. Click Copy, or Download to save a .json file. Turn on "Remember my JSON" only if you want it kept in this browser for next time.

What is JSON?

JSON (JavaScript Object Notation) is the standard format for sending data between web APIs, and it's everywhere in config files and databases too. People can read it, and every modern programming language supports it out of the box. Nearly every REST API, from payment gateways to social media, sends and receives JSON. This JSON formatter makes it readable, checks it for errors and shows it as a tree you can expand and collapse.

Where it comes in handy

  • API debugging: copy a response from Postman or your browser's DevTools and format it so you can actually read it.
  • Config files: tidy up package.json, appsettings.json or tsconfig.json.
  • Data pipelines: validate JSON before it goes into a database or message queue.
  • Log analysis: many logging systems write minified JSON. Format it to find the problem faster.

JSON syntax rules

  • Keys must be strings in double quotes: "name", not name.
  • A value can be a string, number, boolean, null, array or object.
  • Trailing commas aren't allowed, unlike in JavaScript objects.
  • Comments aren't allowed either. If you need them in config files, use a JSON5 parser.

So {'name': 'Asha',} fails twice, once for the single quotes and once for the trailing comma. The valid version is {"name": "Asha"}.

Frequently Asked Questions

The usual ones: missing commas between elements, unclosed brackets or braces, trailing commas (not allowed in JSON), unquoted keys, single-quoted strings, and control characters inside strings. It also tells you if the input is empty or isn't JSON at all.

No. Formatting and validation happen in your browser, using JavaScript's built-in JSON.parse() and JSON.stringify(). Your data never leaves your device, so it's safe to paste sensitive API responses.

JSON5 is a looser superset of JSON. It allows comments (//, /* */), trailing commas, single-quoted strings and unquoted keys. Some config files use it, such as VS Code's settings.json. Standard JSON parsers reject JSON5, so use a dedicated JSON5 parser for those files.