Dev TooloraLocal dev tools

> Formatters

JSONC to JSON

Convert JSONC or JSON5 to strict JSON locally. Comments and trailing commas are removed, and big numbers stay exact.

Runs locallyWorks offline
Back to results
Input

Source data

Input
Indentation
Output

Result

Your result will appear here.

Tool guide

About this tool.

JSONC is JSON with // and /* */ comments and trailing commas, as used by tsconfig.json and VS Code settings. The converter removes comments and trailing commas outside strings and formats the result as strict JSON.

JSON5 mode also accepts single-quoted strings, unquoted keys, hexadecimal numbers, leading or trailing decimal points, + signs and line continuations in strings. Each is rewritten to its strict JSON form.

Paste JSONC or JSON5, or choose a sample.

Choose JSONC for comments and trailing commas, or JSON5 for the full JSON5 syntax.

Pick 2 spaces, 4 spaces or tabs.

Copy the result or save it as a JSON file.

  • { "a": 1, // note } → {"a": 1} formatted, with 1 comment removed.
  • [1, 2,] → [1, 2] without the trailing comma.
  • {a:'x', b:0x1F, c:.5} in JSON5 mode → {"a": "x", "b": 31, "c": 0.5}.
  • {"url": "http://x"} → the // inside the string is kept.

  • Processing is local; nothing is uploaded.
  • Limits: 5,000,000 input characters, 2,500,000 values and 128 nesting levels.
  • Octal escapes such as \1 are rejected, as JSON5 requires.
  • Duplicate keys are kept as written; the summary counts them.
  • Infinity, -Infinity and NaN are rejected because JSON has no equivalent.

FAQ

Questions about JSONC to JSON

Are comments kept?

No. Comments have no place in strict JSON, so they are removed. The summary says how many were removed.

What happens to Infinity and NaN?

JSON has no Infinity or NaN, so these values are rejected with an error. Replace them with null or a string first.

Are big numbers kept exact?

Yes. Numbers are copied as written, so 12345678901234567890123 is not rounded. Hexadecimal numbers are converted exactly.

Can I use single-quoted strings?

Only in JSON5 mode. JSONC mode accepts double-quoted strings only and reports the line and column of a single quote.

Where is the error in my input?

Errors name the line and column of an unterminated string or comment, or of the first invalid JSON token.

Continue with

JSON FormatFormat, minify or validate JSON without rounding numbers, rewriting strings or dropping duplicate keys.JSON Sort Keys & CanonicalizeSort JSON object keys recursively, or produce the RFC 8785 canonical form used for signing and hashing.