JSON5 to JSON Converter

JSON5 is a friendlier superset of JSON: comments, trailing commas, unquoted object keys, single-quoted strings, hex numbers. Browsers and standard JSON parsers reject all of those. This tool strips JSON5 features down to strict JSON that JSON.parse(), json.loads(), and every other compliant parser accepts.

How to use the JSON5 to JSON Converter

Paste your JSON5 (config files, hand-edited data, anything that uses the extended syntax). The converter strips line and block comments, removes trailing commas before ] and }, quotes unquoted keys, normalises single-quoted strings to double-quoted, and converts hex / Infinity / NaN literals to their JSON-safe representation. The result parses cleanly with any strict JSON parser.

About JSON5 to JSON Converter

JSON was designed in 2001 to be the world’s minimal data interchange format: no comments, no trailing commas, double-quoted strings only, no hex numbers, no NaN / Infinity. Those constraints made it parseable in any language with a few hundred lines of code, but they also made hand-edited config painful. JSON5 (“JSON for humans”) extends JSON with the most-requested ergonomics: line and block comments, trailing commas, unquoted identifier keys, single-quoted strings, hex / Infinity / NaN literals, escaped line continuations.

Most tools accept both: Babel’s .babelrc, Prettier configs, VS Code’s .vscode/settings.json, npm’s newer config files — all tolerate JSON5 features. But some downstream tools don’t. APIs that accept JSON bodies reject comments. JSON.parse() in vanilla JavaScript only accepts strict JSON. This converter bridges the gap: write or edit in JSON5, ship strict JSON.

Common use cases

  • API payload preparation — strip comments and trailing commas from a hand-written request body before posting.
  • Cleaning up VS Code settings for a tool that wants strict JSON.
  • Babel / Prettier config sharing — some CI tools choke on JSON5; normalise before commit.
  • Migrating from JSON5 to strict JSON when consolidating on a single config format.

Frequently asked questions

Does it handle every JSON5 feature?

Yes \xE2\x80\x94 line + block comments, trailing commas, unquoted identifier keys, single-quoted strings, hex literals (0x1F), leading / trailing decimal points (.5, 5.), +Infinity / -Infinity / NaN, escaped line continuations.

How are NaN / Infinity handled in the output?

Strict JSON has no representation for them. The converter substitutes null \xE2\x80\x94 the convention many JSON serialisers use. If your downstream consumer needs different handling, edit the output manually.

Does it preserve comments somewhere?

No \xE2\x80\x94 strict JSON has no comment syntax, so they're dropped. Keep your JSON5 source if you need the commentary.