🧾

JSON Formatter & Validator

Beautify, validate, minify and sort JSON with exact error line/column reporting — processed entirely in your browser.

JSON Input

About the JSON Formatter

JSON is the lingua franca of APIs, config files and log exports, but it is unforgiving: one trailing comma, an unquoted key or a stray single quote and the whole document refuses to parse. This tool validates JSON with the exact line and column of the first error, pretty-prints with 2- or 4-space indentation, minifies for compact transport, and optionally sorts object keys alphabetically — useful for producing stable diffs of config files.

The statistics row shows total size, object and array counts, key count and maximum nesting depth, which helps when you are sanity-checking an API response or working out why a config file has become unmanageable. Everything runs in local JavaScript, so API responses containing internal data are safe to paste. For converting JSON to spreadsheets, see the companion JSON to CSV Converter.

How to Use This Tool

1
Paste raw JSON into the input panel — minified API responses, config files or log payloads all work.
2
Click Format (2 spaces) or Format (4 spaces) to pretty-print, or Minify to strip whitespace for transport.
3
If the JSON is invalid, the validator reports the exact line and column of the first error, so you can fix a missing comma or stray trailing bracket immediately.
4
Optionally tick Sort keys A–Z to normalise key order, then Copy the result or Download .json.

Common Use Cases

  • 🔌
    Debugging API responses. Paste a one-line response body from curl or browser dev tools and format it to see the structure you're actually dealing with.
  • ⚙️
    Editing config files. Validate appsettings.json, tsconfig.json or a webhook payload after hand-editing, before an application chokes on it at startup.
  • 📊
    Comparing payloads. Sort keys A–Z on two JSON documents so a text diff shows real differences instead of key-order noise — pairs well with our Text Diff Checker.
  • 📦
    Shrinking payloads. Minify JSON destined for an HTTP body, environment variable or query parameter where every byte counts.
  • 🎫
    Reading log entries. Structured logs often store JSON as a single line; format it to make nested error details readable in an incident.

Common JSON Errors Explained

  • Trailing comma. {"a":1,} is invalid JSON, even though JavaScript accepts it.
  • 🔤
    Single quotes. Keys and strings must use double quotes: {'a':1} fails.
  • 🏷️
    Unquoted keys. {a:1} is a JavaScript object literal, not JSON.
  • 💬
    Comments. JSON has none — // or /* */ break the parse. Some tools accept “JSONC”, but the standard does not.

Frequently Asked Questions

Why does the validator reject JSON that JavaScript accepts?
JSON is stricter than JavaScript object syntax: keys must be double-quoted, trailing commas are forbidden, and comments aren't allowed. If it fails here but works in a JS file, one of those three is almost always the reason.
Is there a size limit?
Everything runs in your browser's memory, so multi-megabyte files work fine on a modern machine. Extremely large documents (tens of MB) may make the tab sluggish while formatting — minify view is lighter than pretty-print.
Why sort keys?
Sorted keys make two JSON documents comparable in a diff tool: the same data always serialises in the same order. It is standard practice for config files kept in version control.
Does minifying change my data?
No — minification only removes whitespace between tokens. Strings, numbers and structure are untouched, and formatting it again restores readability.
How large a document can I paste?
Browsers comfortably handle multi-megabyte JSON. Extremely large files (50 MB+) may make the tab sluggish since parsing happens in memory on your device.