JSON5 / JSONC ⇄ JSON Converter

Paste JSON5 or JSONC — comments, trailing commas, unquoted keys, single quotes, hex numbers — and get strict JSON a normal parser accepts. Or convert plain JSON back to JSON5. Runs entirely in your browser.

Try:
Converted output

About this tool

JSON5 / JSONC ⇄ JSON Converter takes the relaxed JSON people actually write in config files — tsconfig.json, VS Code settings.json, Babel and ESLint configs, .jsonc fixtures — and turns it into strict RFC 8259 JSON that any parser will accept. It also runs the other way, rewriting plain JSON as JSON5 with unquoted keys and single quotes.

The parser reads the full JSON5 grammar, which is a superset of both JSONC and strict JSON:

Everything JSON5-only is normalized on the way out: numbers become plain decimal literals, keys and strings get double quotes, comments and trailing commas disappear.

Worked example

JSONC input:

{
  // the dev server port
  port: 8080,
  /* only these hosts are allowed */
  hosts: ['a', 'b',],
}

Strict JSON output (Direction = JSON5 / JSONC → strict JSON, Indentation = 2 spaces):

{
  "port": 8080,
  "hosts": [
    "a",
    "b"
  ]
}

Going the other way, {"name": "ada", "tags": ["x", "y"]} with Direction = JSON → JSON5 and JSON5: add trailing commas ticked becomes:

{
  name: 'ada',
  tags: [
    'x',
    'y',
  ],
}

And loose numeric syntax is normalized — { mask: 0xff, ratio: .5, missing: NaN, cap: Infinity } with NaN / Infinity in strict JSON = Convert to a string gives:

{
  "mask": 255,
  "ratio": 0.5,
  "missing": "NaN",
  "cap": "Infinity"
}

Options

Limits and edge cases

FAQ

What is the difference between JSON5 and JSONC?

JSONC ("JSON with Comments") is the dialect Microsoft uses for tsconfig.json and VS Code's settings.json: strict JSON plus // and /* */ comments and trailing commas. JSON5 is a larger superset that adds unquoted keys, single-quoted strings, line continuations, hexadecimal and leading-dot numbers, and NaN/Infinity. This converter reads the full JSON5 grammar, so every valid JSONC file is accepted too.

Why did my comments disappear?

Because strict JSON has no way to express them. The conversion keeps data — objects, arrays, strings, numbers, booleans and nulls — and a comment is not data. That applies in the JSON → JSON5 direction as well: the converter has no comments to restore. Keep the commented file as your source and treat the strict JSON as build output.

What happens to `NaN` and `Infinity`?

JSON5 allows them, strict JSON does not, so you choose with the NaN / Infinity in strict JSON option: null (the default, matching JSON.stringify), a string like "NaN" / "Infinity" / "-Infinity" if the downstream code re-parses them, or Refuse the conversion if a non-finite value means the input is wrong. Writing JSON5 keeps the literals as-is regardless of this setting.

Does converting a big config change my numbers?

No. Numbers are carried through as text and only re-spelled where JSON5 syntax requires it — 0xff becomes 255, .5 becomes 0.5, 5. becomes 5, +1 becomes 1 and 007 becomes 7. Long integers and long decimals are not routed through a floating-point value, so a 23-digit ID stays exactly what you typed.

What does the Auto direction do?

It looks at what the input actually used. If the text contains any JSON5-only construct — a comment, a trailing comma, a bare key, a single-quoted string, a hex number, NaN — it converts to strict JSON. If the input was already strict JSON, it converts to JSON5 instead. It is the one-click "give me the other dialect" mode.

Is my JSON uploaded anywhere?

No. The converter is a WebAssembly module that runs inside your browser tab. Your config text is parsed and rewritten locally, and you can copy or download the result without it leaving your device — which matters, because config files often hold host names, ports and internal paths.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool json5-convert "{
  // the dev server port
  port: 8080,
  hosts: ['a', 'b',],
}"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/json5-convert/?text=%7B%0A%20%20%2F%2F%20the%20dev%20server%20port%0A%20%20port%3A%208080%2C%0A%20%20hosts%3A%20%5B%27a%27%2C%20%27b%27%2C%5D%2C%0A%7D&direction=to-json&indent=2&sort_keys=true&nonfinite=null&quote_style=single&unquote_keys=true&trailing_commas=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.