Skip to content
4all.tools

Convert JSONC to JSON and Repair JSON

Convert JSONC comments and trailing commas to strict JSON, or attempt a bounded heuristic repair and review every text change.

Tool workspace

Convert JSONC or repair JSON

JavaScript is required to convert or repair JSON in your browser.

Operation mode

Convert strict JSON, // and /* */ comments, and trailing commas to strict JSON.

JSONC accepts comments and trailing commas. Other JSON syntax must be valid.

0 / 250,000 UTF-16 code units

JSON repair actions

JavaScript is required to convert or repair JSON in your browser.

Result

Ready. Choose a mode and run the operation when you are ready.

Choose a mode

Use JSONC to JSON when the document is JSON with // or /* ... */ comments or trailing commas. The converter removes comments and trailing commas, then checks that the result is strict JSON. Comments do not exist in strict JSON, so they are not preserved in the output.

Choose Repair JSON only when the input also has common mistakes such as single-quoted strings or unquoted property names. Repair uses heuristics and may infer missing values or delimiters. The input stays as you entered it; review the strict JSON candidate and its text changes before copying it.

Examples

JSONC input:

{
  // comments and trailing commas are allowed here
  "name": "Ada",
}

Strict JSON output:

{
  "name": "Ada"
}

Repair input:

{ name: 'Ada', active: true }

One possible strict JSON output:

{"name":"Ada","active":true}

The output examples show equivalent JSON with simplified spacing. JSONC conversion replaces comments and trailing commas with spaces and preserves line breaks; Repair may produce different spacing.

How to use JSON Repair

  1. Paste the original text into Input.
  2. Choose JSONC to JSON or Repair JSON. JSONC is selected initially.
  3. Select Convert or Repair to start the operation.
  4. Review the proposed output, summary, warnings, and every listed change.
  5. Use the range controls to inspect the original or proposed text, then copy the output only when it matches your intent.

Typing and changing modes do not run an operation automatically. The result is cleared when the input or mode changes. Cancelling also leaves the original input unchanged.

Heuristics and uncertainty

Repair is not a reconstruction of the author’s intent. When a document ends mid-value, a repair may infer null or add a closing quote, bracket, or brace. Those choices are guesses: a truncated number, string, or array may have had a different intended value. A Markdown fence that wraps one document may be recognized, but arbitrary prose and multiple unrelated snippets are not universally extracted.

The warning remains visible whenever Repair JSON is selected, including when a valid input passes through unchanged. A successful operation means the candidate passed strict JSON syntax validation. It does not prove that a repair preserved the intended meaning.

Limits and validation

Input is limited to 250,000 UTF-16 code units and candidate output to 500,000. Parsing is bounded to 100 nesting levels, 25,000 JSON nodes, 100 diagnostics, and 1,000,000 work units; repair preflight has its own 1,000,000-work-unit limit. The Worker has a five-second time limit. Detailed change comparison is limited to 2,000,000 work units and 1,000 localized changes; linear change verification has a separate 4,000,000-work-unit limit. When detail cannot be shown safely, changes can be grouped into a wider range. Change rows show 50 items per page and shorten each preview after 240 UTF-16 code units. A limit failure does not expose a partial candidate as usable output.

Duplicate property names and a byte order mark are rejected. The strict JSON validator may also warn when a number could lose precision as a JavaScript number. Check the original spelling of large or precise numbers when that warning appears. Neither mode promises full JSON5 support or exact recovery from damaged input.

Local processing and privacy

Conversion, repair, validation, and change comparison run in a browser Worker on your device. The document is not uploaded to an application server or saved by this tool. Copying uses the browser clipboard only after you request it.

Frequently asked questions

How do JSONC conversion and Repair differ?

JSONC conversion accepts comments and trailing commas around otherwise valid JSON. Repair attempts to address additional common mistakes and may infer content, so its result needs a closer semantic review.

Is this a complete JSON5 converter?

No. It handles the documented JSONC syntax and selected repair cases. JSON5 features such as unquoted special values or its full number syntax are not promised.

Why can Repair leave an error unfixed?

Malformed text can have several plausible meanings. Repair is bounded and heuristic; ambiguous or unsupported input can fail strict validation instead of producing a guess.

What happens to truncated data?

Repair may infer null or closing delimiters to form a parseable candidate. That candidate cannot recover missing source characters, so compare it with the original data before using it.

Why do comments disappear?

Strict JSON has no comment syntax. JSONC conversion removes comments while creating a strict JSON candidate.

Can large numbers change?

JavaScript represents JSON numbers with finite precision. The validator warns when it detects a possible precision loss; keep the original text and verify the value with a representation suited to your data.