← All Tools

JSON5 ⇄ JSON Converter

Parse JSON5 — JSON with comments, trailing commas, unquoted keys, single quotes, hex numbers, NaN / Infinity, and multi-line strings — and emit strict RFC 8259 JSON. Or pretty-print strict JSON as ergonomic JSON5. 100% client-side, no network, no eval.

Input JSON5

Bytes: 0Lines: 0

Output JSON

Bytes: 0Lines: 0Δ —
Ready.

What JSON5 adds on top of JSON

CommentsBoth // line and /* block */ comments are allowed anywhere whitespace is.
Trailing commasObjects and arrays may end with a trailing comma — no more diff churn when reordering fields.
Unquoted keysIdentifier-like keys (foo, $bar, _baz123) skip the quotes.
Single-quoted strings'hello' is equivalent to "hello"; the other quote no longer needs escaping inside.
Multi-line stringsEnd a line with a backslash to continue the string on the next line.
NumbersHex literals (0xDEADBEEF), leading/trailing decimal points (.5, 5.), explicit + sign, and NaN / ±Infinity.

Strict JSON has no representation for NaN or ±Infinity. When converting from JSON5 to JSON, those values become null and a warning is shown — that matches what JSON.stringify does for the same JavaScript values.

JSON5 quick reference

{
  // line comment
  /* block comment */
  unquotedKey: 'single quotes',
  "quoted":   "double quotes",
  hex:        0xCAFE,
  decimal:    .5,
  trailing:   5.,
  positive:   +1,
  infinity:   Infinity,
  nan:        NaN,
  multiline:  "first line \
continued",
  trailing_comma: [1, 2, 3,],
}