Skip to content

Formatters & Code

JSON5 Formatter

Parse JSON with comments and trailing commas.

Runs in your browser
JSON5 formatter & validator
lines: 0chars: 0size: 0 B
JSON5 · UTF-8 · 2-space indent

Understanding JSON5

The relaxed cousin of JSON.

What JSON would have been if it weren't a strict subset of JavaScript object literals.

What JSON5 adds.

JSON5 is a small extension of JSON. It adds the conveniences that human-edited JSON config files desperately wanted: trailing commas, single-line and multi-line comments, single-quoted strings, unquoted keys, NaN and Infinity as numbers, hexadecimal numbers. Every valid JSON document is also a valid JSON5 document.

Where JSON5 lives.

Babel config, Webpack config, Jest config — anywhere a .json file is read by JavaScript tooling, JSON5 tends to show up. package.json is strict JSON; tsconfig.json, .eslintrc.json, and jsconfig.json all accept JSON5 (TypeScript and ESLint specifically allow comments). The convenience of writing a comment next to a config option is the whole reason the dialect exists.

What this formatter does.

The formatter takes JSON5 input — comments, trailing commas, single quotes, unquoted keys — and emits clean, strict JSON. The auto-fix on upload uses the same logic: it strips JSON5-only syntax and outputs a document that any JSON parser will accept. Going the other way (from strict JSON to JSON5) isn't useful — strict JSON is already valid JSON5.

The cleaner's limits.

Real-world configs sometimes contain things the cleaner can't recover: NaN and Infinity have no valid JSON representation, hex numbers (0xFF) need to be expanded to decimal, backtick template literals aren't part of JSON5 anyway. For those exotic cases, you'll need a full JSON5 parser locally — this formatter focuses on the 95% of inputs that are config files lightly relaxed from strict JSON.

Frequently asked questions

Quick answers.

What is JSON5?

A superset of JSON that allows comments, trailing commas, unquoted keys and a few other conveniences. It's the format of many config files (tsconfig, devcontainer, babel) and drift-prone hand-edited JSON.

Does it handle single-quoted strings?

This tool handles the most common JSON5 drift — `// comments`, `/* block comments */` and trailing commas. For the full JSON5 spec (unquoted keys, single quotes, hex numbers) paste into a proper JSON5 parser locally.

What does the output look like?

Strict, spec-compliant JSON — 2-space indented. Safe to feed to any JSON.parse or schema validator.

Is it free?

Yes — fully free, in-browser, no signup.

People also search for

Related tools

More in this room.

See all in Formatters & Code