JSON Formatter

Format and validate JSON. Indented or minified output, with clear error messages.

Loading…

All processing runs in your browser — no files or inputs are uploaded to a server.

How to use

Paste a JSON document on the left to get the formatted result on the right. Pretty mode adds indentation; Minify mode strips whitespace for compact output. Invalid JSON shows the error position with line and column — useful when debugging large API responses or config files where the syntax error is buried.

Indent width is configurable (2, 4, or 8 spaces). The tool runs entirely in your browser, so even huge JSON payloads stay on your machine.

Examples

Pretty-print compact JSON

Input
{"a":1,"b":[2,3]}
Output
{
  "a": 1,
  "b": [
    2,
    3
  ]
}

Default 2-space indent. Switch to 4 or 8 spaces to match your team style.

Minify JSON for transport

Input
{
  "user": "alice",
  "scopes": ["read", "write"]
}
Output
{"user":"alice","scopes":["read","write"]}

Useful when you need a compact payload for an HTTP body or to paste into a config string.

Catch a missing comma

Input
{
  "name": "bob"
  "age": 30
}
Output
Expected , or } at line 3, column 3

Errors come with line + column so you can jump straight to the spot.

FAQ

Does this tool send my JSON to a server?

No. Everything runs in your browser via the standard JSON.parse and JSON.stringify APIs. Your data never leaves the page.

Can I format JSON with comments or trailing commas?

Strict JSON does not allow comments or trailing commas. JSON5 or JSONC files (tsconfig.json, VS Code settings) will be rejected here. Strip comments first or use a JSON5-aware formatter.

Why does Minify keep my Unicode characters instead of escaping them?

JSON.stringify only escapes control characters and quotes. Non-ASCII text like Korean or Japanese is valid JSON and stays readable. If you need ASCII-only output, encode it separately.

Is there a size limit?

No hard cap, but very large documents (10+ MB) may freeze the page during parsing. For huge files prefer a streaming parser like jq.

Are large numbers preserved exactly?

No. Numbers parse into JavaScript's Number type (IEEE 754 double), so integers above Number.MAX_SAFE_INTEGER (2^53 − 1, ≈9.007 × 10^15) silently lose precision. A 19-digit Twitter or Discord snowflake ID round-trips with the wrong final digits. If you need the exact value, quote it as a string in the source JSON before formatting, or use a BigInt-aware parser.

What happens to duplicate keys?

RFC 8259 leaves the behavior implementation-defined, and JSON.parse silently keeps the last occurrence. `{"a":1,"a":2}` becomes `{"a":2}` after formatting — the first value is gone with no warning. Duplicates usually indicate a bug in the producing code, so search the raw input for the suspect key before trusting the formatted output.

Related concepts

JSON (JavaScript Object Notation) is a text format for structured data defined by RFC 8259. A formatter does two things — parse (text → in-memory tree) and serialize (tree → text with chosen whitespace). Errors only surface at the parse step.

Common gotchas: keys must be double-quoted strings, trailing commas are forbidden, and the only allowed primitives are strings, numbers, booleans, null, arrays, and objects. Functions, Date, and undefined cannot appear directly — they need an explicit conversion at the application layer.

Several JSON-adjacent formats look similar but parse differently. JSON5 adds comments, trailing commas, and unquoted keys for human-edited config files. JSONC (used by tsconfig.json and VS Code settings) accepts comments and trailing commas. JSON Lines (NDJSON) drops the outer array and writes one independent JSON object per line, ideal for streaming logs and append-only files. This tool implements strict RFC 8259 only, so any of those variants will throw a parse error. Strip the extras first, or route to a format-aware tool.

Related articles

Related tools