How Deterministic Client-Side JSON Repair Works
Developers constantly copy JSON-like blobs from Python tracebacks (using single quotes and True/False/None), JavaScript console logs (unquoted object keys and trailing commas), JSONC/JSON5 config files (inline // comments), or LLM completions cut off mid-token by max_tokens limits. Naive regex replacements often corrupt valid string contents containing apostrophes, URLs like https://, or escaped quotes.
This repair engine runs a single-pass state-machine lexer directly in your browser. It strips outer markdown code fences, preserves string boundaries while converting single-quoted strings with proper escaping, normalizes Python boolean/null keywords outside strings, removes comments and trailing commas, and balances unclosed arrays or objects so the output passes strict JSON.parse().
- Supported RepairsSingle quotes, unquoted keys, trailing commas, // and /* */ comments, Python True/False/None, markdown fences
- Truncation RecoveryTracks open brace/bracket stack to auto-close cut-off streaming LLM JSON payloads
- Audit TrailDisplays an itemized repair log showing every transformation applied before RFC 8259 validation
Will removing // comments break https:// URLs inside strings?
No. The tokenizer tracks active string state, so comment stripping only executes outside quoted string literals.
Can this fix JSON wrapped in Markdown ```json fences from ChatGPT or Claude?
Yes. Leading and trailing triple-backtick code fences are automatically stripped before lexical repair.
Is the repaired output guaranteed to be strict RFC 8259 JSON?
Yes. Every repaired payload is immediately verified with native JSON.parse() and formatted cleanly with standard double quotes.