← Back to home

JSON Formatter, Validator & Minifier

Last reviewed on April 27, 2026.

Paste JSON into the input. The tool parses it, reports any error with line and column, and writes the formatted version to the output box. Switch indent, sort keys, or minify in the controls. Everything runs locally in your browser — no JSON ever leaves your device.



      
Updates as you type.

What "valid JSON" actually means

JSON is a subset of JavaScript object syntax with a strict set of rules. The parser will reject any of the things developers casually add when hand-writing config:

The three jobs this tool does

Format

Reads the input, parses it as JSON, and re-emits it with consistent indentation. Two-space indent is the default — it is what most code editors and style guides settle on, fits comfortably on a 16:9 screen, and survives diffing reasonably well. Switch to four if you are working in a codebase that already uses four; consistency beats preference.

Minify

Strips every byte of whitespace not strictly inside a string. The output is the smallest valid representation of the same data. Useful when copying a config into a single environment variable, embedding JSON in a JWT payload (see the Base64 encoder), or shipping a fixture inline in a test file. The minifier also normalizes string escapes, so "A" becomes "A" if the original had been over-escaped.

Sort keys

Recursively sorts every object's keys alphabetically. Useful for stable diffs across runs (so two programs that emit the same data in different key orders produce identical output), and for human readability when the input has dozens of fields. Sorting does not change array order — JSON arrays are ordered by definition; sorting them silently would change meaning.

Worked example: comparing two JSON files

You have two configuration files that should be the same but produce different behavior. The fastest path to the difference:

  1. Format both files with the same indent and the sort-keys option on.
  2. Diff the formatted output line by line.
  3. Real differences now show up as line-level changes, not as cosmetic re-orderings.

The same trick works for API responses captured in different runs, snapshot test fixtures, and config exported from different environments.

Reading parse errors

The browser's JSON parser reports errors with a position. The tool above translates that position into a line-and-column reference. The most common errors and what they actually mean:

ErrorWhat it meansFix
Unexpected token }A trailing comma before the closing braceRemove the comma
Unexpected end of JSON inputTruncated input — opening brace without a closing oneCheck that the paste copied the whole thing
Unexpected token 'Single-quoted stringReplace single quotes with double quotes
Unexpected numberUsually a leading-zero number or a misplaced minus signStrip the leading zero or fix the sign
Unexpected token i (or N)Infinity or NaN in the inputReplace with null or remove the field

Common mistakes

Where this fits with the other tools on the site

Use the JSON formatter alongside the URL encoder when you are debugging an API request that puts JSON in a query parameter. After decoding a Base64-encoded payload with the Base64 encoder, paste the result here to validate it. For test data you do not want to invent by hand, generate fake values with the fake prop-data generator, and check the resulting JSON shape here.