Skip to content

JSON Formatter

Format, validate and minify JSON.

Runs in your browser · free · no sign-up

JSON input
Result

About the JSON Formatter

Paste JSON from an API response, a config file or a log and turn it into readable, indented text. If the JSON is invalid you get the error message from the parser so you can fix it quickly. You can also minify JSON to a single line.

JSON is the format most web APIs, configuration files and NoSQL databases use, but the JSON you meet in real life is rarely tidy. API responses arrive as one long line, log files escape everything, and hand-edited config files pick up a stray comma that breaks a deployment. This formatter is for developers, testers, data analysts and anyone who needs to read or fix JSON quickly without installing an editor plug-in.

The tool parses your text with the browser’s own JSON engine, the same strict parser your JavaScript code uses, so if it accepts the input, your application will too. Valid JSON is re-printed with consistent indentation; invalid JSON produces the parser’s error message so you can jump to the problem. Sorting keys alphabetically makes two versions of the same object easy to compare side by side.

How to use the JSON Formatter

  1. 1Paste your JSON into the input box.
  2. 2Click Format (choose 2 or 4 spaces) or Minify.
  3. 3Copy the result. Errors are shown in red if the JSON is not valid.

Key features

  • Indent with 2 spaces, 4 spaces or tabs to match your project’s style.
  • Minify to a single line for request bodies, environment variables or storage.
  • Optional alphabetical key sorting, applied at every level of nesting.
  • Strict validation with the parser’s own error message when something is wrong.
  • Works offline once the page has loaded.

Practical uses

  • Reading a minified API response while debugging a front-end bug.
  • Checking a package.json or tsconfig.json before committing it.
  • Preparing a compact JSON string to paste into a curl command or a test fixture.
  • Comparing two exported records by sorting their keys first.

Example

An API returns {"id":7,"tags":["new","sale"],"price":{"amount":1499,"currency":"PKR"}}. After Format with 2 spaces, each key sits on its own line and the nested price object is indented under its parent, so you can see at a glance that the amount is an integer in the smallest currency unit.

Tips and common mistakes

  • Trailing commas, single quotes and comments are valid in JavaScript but not in JSON; remove them if the parser complains.
  • If the error position points at the very end, a closing bracket or brace is usually missing.
  • Very large numbers (above 2^53) lose precision in JavaScript, so IDs that long should be stored as strings.
  • Use Sort keys before comparing two files in the Code Diff Viewer to avoid differences caused only by key order.

Limitations

  • JSON5, JSONC (JSON with comments) and NDJSON (one object per line) are not accepted as a whole document.
  • Duplicate keys are allowed by the parser, but only the last value is kept in the output.

Privacy

Your JSON is parsed and printed in this browser tab. Nothing is uploaded, which matters when the data contains customer records, tokens or internal configuration.

Frequently asked questions

Is my JSON sent anywhere?

No. It is parsed with your browser’s built-in JSON engine and never leaves the page.

Why does it say "Unexpected token"?

Common causes are trailing commas, single quotes instead of double quotes, or keys without quotes. Standard JSON allows none of these.

What is the difference between format and minify?

Format adds line breaks and indentation for reading. Minify removes all extra spaces to make the data as small as possible.

Can it fix my JSON automatically?

No. Guessing fixes can silently change data, so the tool shows the exact error and leaves the correction to you.

Does formatting change the values?

No. Only whitespace changes, plus key order if you choose Sort keys. Strings, numbers and nesting stay the same.

Related tools

Base64 Encoder / DecoderEncode text to Base64 or decode it back.
URL Encoder / DecoderPercent-encode or decode URLs and query values.
JWT Decoder & BuilderNewDecode a JWT, check expiry, and sign HS256 test tokens.
Unix Timestamp ConverterConvert Unix time to a date and back.