JSON Formatter
Format, validate, and minify JSON data instantly in your browser. No data leaves your device.
About This Tool
Parses pasted JSON, validates syntax, and re-serializes with configurable indentation. Errors include line and column numbers pointing to the offending token. Minify mode strips all whitespace for compact transmission.
Supports JSON5-style trailing commas and comments via an extended parsing mode, though strict RFC 8259 mode is the default.
JSON (JavaScript Object Notation) was originally specified by Douglas Crockford in 2001 and standardized in RFC 4627 (2006), updated to RFC 7159 (2013) and RFC 8259 (2017), the current authoritative specification. The format is a strict subset of JavaScript object literal syntax: double-quoted strings only, no trailing commas, no comments, no unquoted keys. Strict adherence to the spec ensures interoperability between any two implementations that both claim JSON support. The browser's JSON.parse implements RFC 8259 exactly; rejecting any input that violates the spec is by design.
A worked example: pasting '{"name": "Alice", "age": 30, "hobbies": ["reading", "hiking"]}' parses successfully and re-serializes with 2-space indentation as a multi-line block. Common syntax errors and their causes: trailing comma after the last array or object element ('hobbies": ["reading", "hiking",]') is invalid in strict JSON though valid in JavaScript; single quotes ('{\'name\': ...}') invalid; unquoted keys ({name: ...}) invalid; JavaScript-style comments (// or /* */) invalid; JavaScript number literals like NaN, Infinity, or 1_000 invalid (RFC 8259 numbers are decimal-only).
JSON5 extends JSON with several JavaScript-style relaxations: comments, trailing commas, single quotes, unquoted keys, multi-line strings (via backslash-newline continuation), and hex numbers. JSON5 is not interchangeable with strict JSON for transmission (most servers reject it) but it's much friendlier for human-edited config files; the .json5 extension and dedicated parsers (json5 npm package) handle the format. The formatter here offers an extended-parsing mode that accepts JSON5 input and re-emits strict JSON output, useful for converting hand-edited config to a transmission-safe format.
Limitations are mostly about size and type fidelity. The browser's JSON.parse handles arbitrary-size inputs but indentation and pretty-printing roughly double memory usage temporarily; multi-megabyte JSON files may take a noticeable second to format. JSON cannot represent JavaScript's full type set: Date, undefined, Function, Symbol, BigInt, and circular references all fail to round-trip. Common workarounds are ISO-8601 strings for dates, explicit nulls for undefined, and JSON references ($ref convention) for shared sub-objects, but none are part of the JSON spec itself.
Key ordering is technically not significant per the spec (object members are unordered), but most parsers preserve insertion order when re-serializing, and many tools treat order as informationally meaningful. Sorting keys alphabetically helps with diffs (semantically identical objects produce identical text) and reproducibility (order-dependent output becomes deterministic). The formatter offers sort-keys as a toggle for these workflows.
The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.