Skip to content

JSON Formatter & Validator (Private, Runs Locally)

JSON formatter and validator that runs 100% in your browser. Beautify, minify, sort keys, and find errors by line. Nothing is uploaded or saved.

By Updated Runs in your browser

JSON Formatter guide

Format messy JSON, validate API responses, minify payloads, and pinpoint syntax errors by line and column. Your JSON never leaves your device: no server, no save button, no shareable links.

What formatting actually does

The formatter parses your input with the browser's native JSON parser and re-serializes it with two-space indentation. If the parse fails, you get the exact error message and nothing is guessed or auto-fixed. Minify does the same parse but outputs with no whitespace at all.

Because the output comes from a real parse, a successful format also proves the JSON is valid. That is more reliable than a regex-based beautifier that only adds line breaks.

The five errors that break most JSON

Trailing commas: {"a": 1,} is legal in JavaScript but not in JSON. Remove the last comma in every object and array.

Single quotes: JSON requires double quotes around strings and keys. {'name': 'Ada'} fails; {"name": "Ada"} works.

Unquoted keys: {name: "Ada"} is a JavaScript object literal, not JSON. Every key needs double quotes.

Comments: JSON has no comments. Config formats like JSONC or JSON5 allow them, but a strict parser will reject // or /* */.

Special values: NaN, Infinity, undefined, and functions are not valid JSON. Use null or a string instead.

Worked example: fixing an API payload

Input: {user: 'ada', roles: ['admin', 'dev',], active: true}. The parser stops at the first problem, the unquoted key. Fix all three issues at once and you get {"user": "ada", "roles": ["admin", "dev"], "active": true}. Format it and each key lands on its own line, making nested structures easy to scan.

Error positions help. "Unexpected token } in JSON at position 42" means character 42, counting from zero. Look just before that point; the real mistake is usually one character earlier, often a trailing comma.

Large numbers lose precision

JavaScript stores numbers as 64-bit floats, which are exact only up to 9,007,199,254,740,991 (2^53 − 1). A JSON ID like 9007199254740993 will quietly become 9007199254740992 after parsing and formatting. Twitter-style snowflake IDs and some database keys exceed this. If exact digits matter, have the API send them as strings.

JSON versus JavaScript objects

JSON looks like JavaScript but is stricter by design. It supports exactly six value types: string, number, boolean, null, object, and array. No dates, no undefined, no functions, no comments. Dates are usually sent as ISO 8601 strings such as "2026-09-25T14:30:00Z" and parsed on the other side.

Key order is not guaranteed to mean anything, and duplicate keys are technically allowed by the grammar but handled inconsistently: most parsers, including the one in your browser, keep the last value. If an API response seems to ignore a field, search the raw payload for a duplicate key.

Reading large payloads

For big responses, format first, then use your browser's find to jump between keys. Nested arrays of objects are easier to scan once each object sits on its own lines. If the payload is a list of records you want in a spreadsheet, the JSON to CSV converter flattens it into rows.

Very large files, tens of megabytes, may slow the page because everything runs on your device. For those, a command-line tool like jq is the better choice: jq . file.json pretty-prints and jq -c . file.json minifies.

Formatting versus minifying

Pretty JSON is for humans: code review, debugging, documentation. Minified JSON is for machines. Stripping whitespace typically shrinks a file by 10 to 30 percent before compression, though gzip or Brotli closes most of that gap on the wire.

Everything runs locally in your browser. API responses, tokens, and customer data you paste here are never uploaded, which matters when you are debugging production payloads. Still, rotate any secret you accidentally paste anywhere.

How we calculate: sources

Frequently asked questions

Is it safe to paste API keys or customer data here?

The formatting happens entirely in your browser with the built-in JSON.parse, and there is no save or share feature, so nothing is sent anywhere. In November 2025, watchTowr Labs reported downloading 80,000+ publicly listed saved pastes from the save-and-share features of jsonformatter.org and codebeautify.org, and finding Active Directory passwords, database credentials, cloud keys, and private keys among them. A local tool with no save feature avoids that risk.

How do I validate JSON?

Paste it in. The tool parses it as you type and shows Valid JSON, or the parser's error with the line and column where it failed.

What are the most common JSON errors?

Trailing commas after the last item, single quotes instead of double quotes, unquoted keys, comments, and values like undefined or NaN. All are valid in JavaScript but invalid in strict JSON (RFC 8259).

What does minify do?

It removes all whitespace outside strings, so deeply nested, pretty-printed JSON often shrinks by a quarter or more. That helps when pasting into env vars, headers, or config fields.

Should I use 2 or 4 space indentation?

2 spaces is the most common choice: npm writes package.json with 2 spaces, and most JavaScript style guides use it. 4 spaces is common in Python projects. Tabs are fine too. Pick one and stay consistent.

What does sort keys do?

It reorders object keys alphabetically at every level, which makes two JSON documents much easier to compare in a diff. Array order is never changed.

Is there a size limit?

No fixed limit. Files of several megabytes format in well under a second on a modern laptop. Very large files (100 MB+) may be slow because everything runs in one browser tab.

Is my data uploaded?

Everything runs in your browser. Nothing you enter is uploaded to a server or stored by us.

Why does my JSON say unexpected token?

The parser hit a character it did not expect, usually a trailing comma, single quote, unquoted key, or comment. Check the character just before the reported position.

Can JSON have comments?

No. Standard JSON does not allow comments. Formats like JSONC and JSON5 do, but they need a different parser.