What is LLM JSON Fixer?
LLM JSON Fixer turns the almost-JSON that large language models produce into strict, valid JSON. When you ask a model for structured output, the reply often arrives wrapped in a ```json markdown fence, preceded by a sentence like "Here is the JSON:", sprinkled with // comments, written with single quotes or Python literals (True, False, None), littered with trailing commas, or cut off mid-object because the response hit its token limit. JSON.parse rejects all of these, which breaks agent pipelines, function-calling handlers and data-extraction scripts. This tool reads the input with a forgiving parser that understands those mistakes, rebuilds the data, and re-serializes it as standards-compliant JSON (RFC 8259). Every repair is listed with the line where it was first found, so you can see exactly what changed instead of trusting a black box. Input that is already valid passes through unchanged.
How to use LLM JSON Fixer
- Paste the raw model response into the left panel. Leave in the code fences, explanations and any truncated ending; the fixer finds the JSON itself.
- The repaired JSON appears instantly on the right, with an interactive tree view for exploring nested data.
- Check the repair summary under the workspace to see which problems were fixed and on which line each one first appeared.
- Use the Indent button to switch between 2-space, 4-space and minified output.
- Copy the result or download it, then feed it back into your code, prompt or test fixture.
Key features
- Extracts JSON from markdown code fences and surrounding chatty prose
- Fixes single quotes, curly smart quotes, unquoted keys and unescaped inner quotes
- Removes trailing commas and comments; inserts missing commas and colons
- Converts Python True/False/None and JavaScript undefined/NaN/Infinity
- Closes strings, arrays and objects left open by truncated (max_tokens) output
- Unwraps double-encoded and backslash-escaped JSON strings
- Lists every repair with the line where it first occurred
- Preserves large integers exactly and leaves valid JSON untouched
- 100% client-side: deterministic, private and works offline
Common use cases
- Parsing structured output from ChatGPT, Claude, Gemini, Llama or other models when it fails JSON.parse
- Recovering usable data from a response that was cut off by the max_tokens limit
- Debugging function-calling and tool-use arguments that a model returned with syntax errors
- Converting Python dict reprs or print() output from notebooks into real JSON
- Cleaning JSON copied from logs, where it was escaped as {\"key\": \"value\"}
- Turning JSON Lines (one object per line) into a single JSON array
Technical details & standards
The fixer is a deterministic recursive-descent parser, not an AI model, so the same input always produces the same output. It first extracts the body of a ```json fence (closing fences escaped inside JSON strings are ignored), skips any leading or trailing prose, and unwraps payloads that were double-encoded as a JSON string or backslash-escaped (for example {\"a\": 1} copied from a log). While parsing, it accepts single, backtick and curly quotes; unquoted keys and bare-word values; //, /* */ and # comments; True/False/None and undefined/NaN/Infinity; hex, leading-dot and leading-plus numbers; missing or extra commas and colons; ellipsis placeholders; MongoDB-style wrappers such as ObjectId("..."); Python tuples; and string concatenation. An unescaped quote inside a string is detected by checking what follows it. Valid JSON always closes a string right before a delimiter, so this heuristic never alters input that is already correct. Brackets left open by truncated output are closed in the right order, and several top-level values (JSON Lines) are wrapped in an array. Numbers are carried through as their original digits instead of being converted to floating point, so 64-bit IDs such as 12345678901234567890 are not rounded the way a JSON.parse round trip would round them. Everything runs locally in your browser; nothing is uploaded or logged.
Frequently asked questions
Why do LLMs return invalid JSON?
Language models generate text token by token and imitate the formats they saw in training, which include JavaScript object literals, Python dicts and markdown code blocks. Without strict structured-output or JSON mode, they often add explanations, comments or trailing commas, and long responses can be cut off by the token limit before the closing brackets are written.
Will the fixer change my data?
Valid JSON passes through unchanged. For broken input, only syntax is repaired: quotes, commas, brackets and literals. Values keep their content, numbers keep their exact digits, and anything ambiguous (such as a bare word like red) becomes a string rather than being dropped. Review the repair summary to see every change.
What happens with truncated JSON?
Open strings, arrays and objects are closed in the correct order, a dangling key gets a null value, and a cut-off true/false/null is completed. The last item may be incomplete because its content was never generated, so check it before using the data.
Is my data sent to an AI service?
No. The repair is done by a deterministic parser running in your browser. Nothing you paste is uploaded, logged or sent to any model.
How is this different from the JSON Formatter or JSON Validator?
The formatter and validator follow the strict JSON standard, so they only tell you where the syntax is wrong. The LLM JSON Fixer repairs those errors for you and then formats the result.
How can I stop getting broken JSON from a model in the first place?
Use the provider's structured-output, JSON mode or tool-calling feature where available, give the model an explicit JSON schema, ask for JSON only with no prose or code fences, and allow enough output tokens for the full response. Keep a repair step like this one as a fallback for the cases that still slip through.
Is my data safe?
All processing happens entirely in your browser. Your data never leaves your device and is never sent to or stored on a server.
Does it work offline?
Yes. Once the page has loaded, most tools keep working without an internet connection.