Skip to content
Processing locally — files never leave your device

JSON Formatter, Validator & Minifier

Pretty-print, minify, and validate JSON. Catches syntax errors with line and column reporting.

Bloggers — embed this widget for free

Add this tool to your own site with one line of HTML. Free forever — just keep the small credit link.

How to use JSON Formatter

  1. Paste your JSON into the input area on the left.
  2. Click "Format" to pretty-print, or "Minify" to strip whitespace.
  3. If the JSON is invalid, you'll see a precise line-and-column error message.
  4. Copy the result with one click, or download it as a .json file.

Format, validate, and minify JSON without it leaving your browser

JSON is the lingua franca of web APIs, configuration files, and structured logs. It's also painful to read when it arrives minified or hand-edited. Whether you're debugging a webhook payload, comparing two API responses, or cleaning up a copy-pasted config, this formatter validates the input with the browser's own strict JSON parser and rewrites it with consistent indentation — entirely on your machine. JSON often contains access tokens, internal IDs, or customer data; none of it should be posted to someone else's server just to add line breaks. Open the network tab and watch: zero requests fire when you click Format.

JSON's strict syntax, and where it bites

JSON looks like a JavaScript object literal but is far stricter, and the gap between the two causes most validation failures. The rules: every key must be a double-quoted string, strings must use double quotes (never single), trailing commas are forbidden, comments are forbidden, and the only literals allowed are true, false, and null — no undefined, no NaN. A snippet that is perfectly valid JavaScript fails as JSON:

// Invalid JSON (valid JavaScript)
{ name: 'Ada', roles: ['admin',], }

// Valid JSON
{ "name": "Ada", "roles": ["admin"] }

When parsing fails, the tool reports the exact line and column, so a trailing comma buried on line 412 of a config file takes seconds to find instead of minutes of squinting.

Format vs. minify

Formatting and minifying are two sides of the same operation: parse first, then re-serialize. Formatting emits indented output for humans; minifying strips every byte of insignificant whitespace for machines. On a typical pretty-printed API response, whitespace accounts for 20–40% of the file, so minifying before embedding JSON in a query parameter, a JWT claim set, or an environment variable is a real saving. Because both paths run the parser, either one doubles as a validity check — a single stray comma that would break a deploy gets caught here first.

Practical uses

  • Pretty-print a webhook or API payload so you can actually see the field you're after.
  • Validate a config file before committing — strict parsing catches what a lenient editor lets through.
  • Format two responses with "Sort keys" enabled, then diff them to spot the real change rather than noise from key order.
  • Minify JSON destined for a data attribute, URL parameter, or inline script tag.

Pitfalls and when not to use it

Two limits are worth knowing. First, JavaScript stores all numbers as 64-bit floats, so integers above 2^53 − 1 (9,007,199,254,740,991) silently lose precision — a 64-bit ID like 1234567890123456789 comes back rounded. If your payload carries IDs that size, keep them as strings. Second, this is a syntax validator, not a schema validator: it confirms the document is well-formed JSON, not that it matches your API contract. And if your file has comments or trailing commas on purpose — JSONC files like tsconfig.json, or JSON5 — strict parsing will reject it by design.

Related tools

Frequently asked questions

Does a webhook payload I paste here get stored anywhere?
It does not — the formatter calls JavaScript’s native JSON.parse in the tab, so a production response full of customer fields or internal IDs is reshaped on your device and never written to any server we run.
How big can my JSON be?
There is no fixed limit. The tool can format JSON files in the tens of megabytes; the practical ceiling is whatever your browser tab's memory allows. For very large files (100 MB+), expect a brief pause while parsing.
What does the error message tell me?
When JSON is invalid, the tool surfaces the exact position of the failure (line and column) along with the parser's message. The most common cause is a trailing comma, an unquoted key, or a single quote where a double quote was expected.
Can I sort keys alphabetically?
Yes — toggle "Sort keys" before formatting. The tool does a deep recursive sort so nested objects are sorted too. Arrays are left in their original order to preserve meaning.
What is the difference between formatting and validating?
Validation only checks that the input is well-formed JSON; formatting validates and then rewrites it with consistent indentation. Minify also validates first, then strips whitespace to produce the smallest valid representation.
Does formatting ever change my data?
Values and key order are preserved (unless you enable key sorting), but there are two edge cases. Integers larger than 9,007,199,254,740,991 (2^53 − 1) are rounded because JavaScript parses all numbers as 64-bit floats — 64-bit database IDs are the classic victim. And if an object contains duplicate keys, only the last one survives parsing.
Why does the parser reject comments?
The JSON specification has no comment syntax — that is deliberate, to keep the format simple and unambiguous. Files like tsconfig.json that contain // comments are actually JSONC, a superset. Strip the comments before validating, or the parser will fail at the first slash.
How much smaller does minifying make a file?
For a typical pretty-printed API response, whitespace is 20–40% of the bytes, so a 1 MB formatted file usually minifies to 600–800 KB. The saving depends on nesting depth: deeply indented structures carry more whitespace per line of data.

More tools you might find useful in the same flow.

Built by Muhammad Tahir · About