Skip to content

JSON5 to JSON Converter

Turn JSON5 or JSON with comments into strict JSON and see exactly what changed.

Output
Runs in your browser — your data is not uploaded.

How to use

  1. Enter your text in JSON5 / JSONC input, or click Upload to select a .json5, .jsonc, .json or .txt file.
  2. Set Output to Pretty or Minified. For Pretty, choose an Indent; enable Sort keys if you want keys sorted.
  3. Choose Replace with null, Convert to strings, or Show an error for Infinity and NaN.
  4. Check Strict JSON and the conversion report. Conversion is automatic up to 1 MB; for larger inputs, click Convert.
  5. Click Copy or Download to save the result, or Copy report to save the change list.

Examples

Remove comments from tsconfig.json

Input
{
  // Visit https://aka.ms/tsconfig
  "compilerOptions": {
    "target": "ES2022",
    "strict": true, // recommended
  },
}
Output
{
  "compilerOptions": {
    "target": "ES2022",
    "strict": true
  }
}

Sort a config and preserve Infinity as a string

Input
{
  retryLimit: Infinity,
  name: 'Staging API',
  flags: 0x1F,
  timeout: NaN,
}
Output
{
    "flags": 31,
    "name": "Staging API",
    "retryLimit": "Infinity",
    "timeout": "NaN"
}

Minify a payload with a large ID

Input
{id: 12345678901234567890, items: [{sku: 'A-1', qty: +2,}, {sku: 'B-7', qty: .5}],}
Output
{"id":12345678901234567890,"items":[{"sku":"A-1","qty":2},{"sku":"B-7","qty":0.5}]}

JSON5 → JSON: what changes

ChangeJSON5 inputJSON output
Comments removed{"a": 1 // note}{"a": 1}
Trailing commas removed[1, 2,][1, 2]
Property names quoted{name: 1}{"name": 1}
Single-quoted strings converted'say "hi"'"say \"hi\""
Hexadecimal numbers to decimal0x1F31
Numbers normalized+1, .5, 5.1, 0.5, 5
Multi-line strings joined'a\↵b'"ab"
Escape sequences converted'\x41\v'"A\u000b"

FAQ

Can I convert JSONC to JSON and keep the comments?

JSONC is accepted, but converting to strict JSON removes comments and trailing commas. To keep comments, use the JSON5 Formatter instead.

How are Infinity and NaN converted to JSON?

By default, they become null; you can instead choose Convert to strings or Show an error. String conversion produces "Infinity", "-Infinity" and "NaN", dropping the plus sign on +Infinity and any sign on NaN. Every replacement is reported with its line and column.

Will large numbers lose precision during conversion?

Numbers without JSON5-specific syntax are copied exactly as written, including 12345678901234567890, 1.10 and -0. Hexadecimal numbers are converted to decimal exactly, even for long values; this does not guarantee that downstream software will preserve their precision.

Why won't my JSON5 convert?

Leading zeros such as 01, values such as True, None or undefined, and curly quotes are not valid JSON5. The Invalid JSON5 panel shows the error location; click the message to move to it in the editor.

Is my data uploaded or saved?

Conversion runs in your browser, and the tool does not upload your input. Only option settings are saved in localStorage; opening a related tool temporarily passes the text through sessionStorage, where the next page removes it after reading. The page also sends analytics events containing the tool slug, not your input.