JSON Formatter & Validator

Paste JSON to pretty-print it, minify it or find exactly where it is broken.

How to format and validate JSON

  1. Paste your JSON into the input box (or click Sample to try it).
  2. Click Format / Validate. Valid JSON is pretty-printed with your chosen indentation; invalid JSON shows the exact line and column of the error.
  3. Use Minify for compact output, Sort keys for a stable order, then copy or download the result.

Common JSON errors and how to fix them

  • Trailing comma: [1, 2,] is invalid. Remove the comma after the last item.
  • Single quotes: JSON requires double quotes: {"name": "Ann"}, not {'name': 'Ann'}.
  • Unquoted keys: {name: 1} is JavaScript, not JSON. Quote the key.
  • Comments: standard JSON doesn't allow // or /* */ comments.
  • Special values: undefined, NaN and Infinity are not valid JSON values.

Why sort keys?

Sorting object keys alphabetically makes two JSON documents easy to compare. Format both with sorting turned on, then paste them into the Diff Checker to see real differences instead of reordering noise.

Working with tokens or encoded data? Try the JWT Decoder and Base64 Decoder.

Validating JSON from APIs and config files

When an API request fails with a vague “Bad Request” or a config file refuses to load, the cause is often invalid JSON. Paste the body here to see the exact line and column of the first error. Common culprits in config files are trailing commas left after removing an item, comments copied from documentation, and Windows-style smart quotes pasted from word processors, which look like quotes but are not valid JSON characters.

JSON vs. JavaScript objects

JSON looks like JavaScript but is stricter. Keys must be in double quotes, strings must use double quotes, and only these values are allowed: strings, numbers, true, false, null, objects and arrays. Functions, dates, undefined, comments and trailing commas are all invalid. If you copied an object from JavaScript code, you may need to fix these details before it becomes valid JSON.

Indentation styles

Two spaces is the most common style for JSON in web projects and is used by tools such as npm and Prettier. Four spaces is common in Python and Java projects, and tabs are preferred by some teams for accessibility. Minified JSON, with no whitespace at all, is used when sending data over the network or embedding JSON in other files.

Large JSON files

Because everything runs locally, you can format multi-megabyte API responses or log exports without waiting for an upload. For extremely large files (hundreds of megabytes) a command-line tool such as jq may be faster.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and validation run entirely in your browser, so API keys, tokens and customer data in your JSON stay private.

Why is my JSON invalid?

The most common causes are trailing commas, single quotes instead of double quotes, unquoted property names, and comments. The error message shows the line and column of the first problem.

What does minify do?

It removes all unnecessary whitespace and line breaks, producing the smallest valid JSON. This is useful for config values, URLs or reducing payload size.

Does it support large files?

Yes. Several megabytes of JSON format in well under a second on most devices.

Last updated · By the Toolbenchly team · How we build and test our tools