Web Development & SEO

JSON Formatter & Validator

This JSON formatter parses your text, then re-prints it with consistent indentation (beautify) or with all optional whitespace removed (minify). When the JSON is invalid, a strict parser walks the text character by character and reports the exact line, column and reason, such as a trailing comma or single quotes, and highlights that line.

Last updated Reviewed by ToolsPulse Hub

Paste, type or drop a .json file. Processing happens in your browser.

Result

  

Waiting for input.

How to use the JSON formatter

  1. Paste JSON into the input box, or drag a .json file onto it. Use “Load sample” to try the tool first.
  2. The text is checked as you type. Valid JSON appears formatted on the right with line numbers. Files over 200 KB wait until you press Format, and the limit is 10 MB.
  3. Choose 2 spaces, 4 spaces or tabs, and tick “Sort keys” to order object properties alphabetically.
  4. Press “Minify” to remove all optional whitespace, for example before putting JSON in a config value or an HTTP header.
  5. Copy the result or download it as a file.

How validation and error finding work

The tool uses its own strict parser that follows the JSON grammar in RFC 8259 and stops at the first rule broken. Browsers word their built-in errors differently (Chrome reports a character position, Firefox a line and column, Safari often neither), so a dedicated parser gives the same clear message everywhere. It also copies every number exactly as written. The browser’s JSON.parse would round 12345678901234567890 to 12345678901234567000 and print 1.10 as 1.1; here both stay untouched when you beautify, minify or sort keys.

value = object | array | string | number | true | false | null object = "{" [ string ":" value *( "," string ":" value ) ] "}" array = "[" [ value *( "," value ) ] "]" line = count of line breaks before the error + 1 column = characters since the last line break + 1

Worked example

This object was copied from a JavaScript file:

{
  "plan": "pro",
  "seats": 5,
}

JavaScript allows the comma after 5, but JSON does not. The status bar reads Line 4, column 1 with the reason “Trailing comma before } is not allowed in JSON”, and line 4 is highlighted. Delete the comma and the formatted result appears at once.

The mistakes that break JSON most often

  • Trailing commas after the last item, common when copying from JavaScript.
  • Single quotes around keys or strings. JSON only accepts double quotes.
  • Unquoted keys such as {name: "Ana"}.
  • Python or SQL literals like True, None or NULL instead of true and null.
  • Comments. JSON has no comment syntax; JSONC and JSON5 do, but standard parsers reject them.
  • Raw line breaks inside strings, which must be written as \n.

Key features

  • Exact line and column for every syntax error, with a readable reason.
  • Large IDs and long decimals are kept digit for digit, with a note when JavaScript could not store them.
  • Beautify with 2 spaces, 4 spaces or tabs; minify to one line.
  • Optional alphabetical key sorting, which makes two JSON files easy to compare.
  • Counts keys, nesting depth and the size before and after formatting.
  • Runs locally, so API keys and customer data in the payload stay private.

Practical use cases

Reading API responses. Paste a one-line response from a log or browser network tab to see its structure. Sorting keys helps when two responses need comparing side by side.

Fixing configuration files. Tools such as package.json, tsconfig.json and many CI settings fail to load on a single stray comma. The line and column point straight to it.

Shrinking payloads. Minifying a pretty-printed document often removes 15% to 30% of its size, which matters for local storage limits and large API requests.

Frequently asked questions

This tool runs entirely in your browser and is provided as-is. See our terms and privacy policy.