JSON Repair vs JSON Validation — What's the Difference? (2026)
JSON repair fixes broken JSON. JSON validation checks if JSON is correct. Learn when you need repair vs validation, what each tool does, and which one your workflow actually requires.
Have broken JSON right now? Fix it free in under 1 second — no signup.
Fix My JSON →Most developers hit a broken JSON error and Google "json repair" or "json validator" interchangeably. They're not the same thing — and using the wrong tool wastes time.
This guide explains exactly what separates JSON repair from JSON validation, when you need each, and how modern tools combine both.
The One-Line Difference
JSON validation answers: Is this JSON valid? (yes / no + error location) JSON repair answers: This JSON is broken — here's the fixed version.A validator is a diagnostic tool. A repair tool is a fix. If your JSON is broken, validation alone doesn't help you — it just confirms what you already know.
What JSON Validation Does
A JSON validator parses your JSON against the RFC 8259 specification and returns one of two results:
- Valid — the JSON is syntactically correct
- Invalid — the JSON has an error, with a position and description (e.g.,
Unexpected token , at position 47)
Tools in this category: JSONLint, JSON Schema Validator, online validators, JSON.parse() in JavaScript, json.loads() in Python.
What validators do not do: fix anything. They report the problem and stop.
When validation is enough
Use a validator when:
- You're writing JSON by hand and want to check your work before submitting
- You need to confirm that an API response you received is valid before processing it
- You're enforcing a JSON Schema (structure validation, not just syntax)
- You're debugging and want to find the exact line and position of a syntax error
Validation is the right choice when the JSON should be correct and you want to verify it is.
What JSON Repair Does
A JSON repair tool takes invalid JSON and returns valid JSON. It doesn't just find the error — it fixes it, then validates the result to confirm the repair succeeded.
The best repair tools handle multiple concurrent errors in a single pass:
| Error | What repair does |
|---|---|
Trailing comma {"a":1,} | Removes the trailing comma |
Single quotes {'key': 'val'} | Converts to double quotes |
Unquoted keys {name: "Alice"} | Adds required double quotes |
Python booleans True/False/None | Converts to true/false/null |
Markdown fences `json ... ` | Strips the code block wrapper |
Truncated JSON {"data":[1,2 | Closes unclosed brackets and strings |
JS comments {"a":1 // note} | Removes all comment syntax |
NaN/Infinity values {"x": NaN} | Replaces with null |
Try it: paste any broken JSON into the JSON Repair Tool and see exactly what gets fixed and why.
When repair is the right choice
Use a repair tool when:
- You're receiving AI-generated JSON from ChatGPT, Claude, or Gemini that includes trailing commas or markdown wrappers
- You're working with n8n, Make.com, or Zapier workflows that produce JavaScript object literals instead of strict JSON
- You're processing API responses that may be partially malformed or truncated
- You're debugging a production issue and need to recover data from a broken JSON log
If you already know the JSON is wrong and you need a fixed version, a repair tool is the right starting point — not a validator.
Repair vs Validation: Side-by-Side
| JSON Validation | JSON Repair | |
|---|---|---|
| Input | Any string | Invalid JSON |
| Output | Valid / Invalid + error location | Valid JSON |
| Fixes errors | No | Yes |
| Explains changes | Reports the error | Can show diff of what changed |
| Best for | Confirming correct JSON | Recovering broken JSON |
| Example tools | JSONLint, JSON.parse() | AI JSONMedic, jsonrepair library |
| Use in production | API input validation, schema enforcement | LLM output handling, data pipeline recovery |
The Modern Workflow: Repair Then Validate
In production systems that process LLM output or user-submitted JSON, the standard pattern is:
- Attempt repair on any incoming JSON
- Validate the result to confirm repair succeeded
- Parse the validated JSON for use
This is more robust than validate-only, because it handles the 5–30% of AI-generated JSON that arrives with minor syntax errors. Throwing an error on that 30% and forcing a retry is slower and more expensive than a repair step that costs microseconds.
# Python example: repair-then-validate pattern
from json_repair import repair_json
import json
def safe_parse_json(raw: str) -> dict:
# Step 1: repair
repaired = repair_json(raw, return_objects=True)
if repaired is None:
raise ValueError("JSON could not be repaired")
# Step 2: validate by re-serializing and parsing
return json.loads(json.dumps(repaired))
// TypeScript example: repair-then-validate
import { jsonrepair } from 'jsonrepair';
function safeParseJson(raw: string): unknown {
// Throws if not repairable
const repaired = jsonrepair(raw);
return JSON.parse(repaired);
}
JSON Schema Validation — A Third Category
There's a third concept worth distinguishing: JSON Schema validation. This is different from both repair and basic syntax validation.
- Syntax validation (RFC 8259): Is this valid JSON at all?
- Schema validation (JSON Schema): Does this valid JSON match the expected structure, types, and constraints?
For example, your JSON might be syntactically valid but fail schema validation because a field that should be a number is a string, or a required field is missing.
If you're working with MCP (Model Context Protocol) servers or building APIs that consume LLM output, you'll often need all three: repair the syntax, then validate the structure against your schema. See the MCP JSON Schema errors guide for common failures in that context.
Tools That Do Both
Most repair tools validate after repairing — that's how they confirm the repair worked. Some tools go further:
AI JSONMedic JSON Repair Tool- Repairs syntax errors (14 error types)
- Validates the result automatically
- Shows a plain-English explanation of every change
- Runs entirely client-side — your data never leaves the browser
- Validates syntax only (for when you need to confirm correct JSON)
- Points to the exact error location
- Suggests what kind of repair is needed
If your JSON is broken and you need it fixed: start with the repair tool. If your JSON should already be correct and you need to confirm it: use the validator.
Quick Decision Guide
Start with repair if:- The JSON came from an AI model (ChatGPT, Claude, Gemini, etc.)
- The JSON came from a no-code/automation tool (n8n, Make.com, Zapier)
- You're getting a parse error on data you didn't write yourself
- The JSON is from a streaming API that may have been truncated
- You wrote the JSON yourself and want to check it
- You're confirming that an API response is well-formed before processing
- You need to enforce a JSON Schema (structure + types)
- You already have valid JSON and want to verify nothing changed
FAQ
Can I repair JSON without validating it first?
Yes. A repair tool doesn't require you to validate first — you can paste any string and it will attempt repair. Under the hood, it validates after repairing to confirm the output is valid. If the input turns out to already be valid, a good repair tool will return it unchanged.
What if my JSON is too broken to repair?
Most JSON repair tools can recover partial JSON and return whatever structure they can reconstruct. Extremely broken inputs (binary data, completely corrupted files) may not be recoverable. In those cases, repair will return the closest valid structure it can construct from the fragments it can parse.
Is JSON validation always free online?
Yes — there are many free JSON validators online, including JSONLint, JSON Editor Online, and the validator at AI JSONMedic. No signup is required for any of them.
What's the difference between a JSON validator and a JSON linter?
A JSON validator checks syntax only. A JSON linter (like ESLint's json plugin) can also enforce style rules: indentation, key ordering, maximum nesting depth, and similar conventions. For most repair scenarios, a validator is sufficient.
Does repairing JSON change its meaning?
Good repair tools are conservative — they only fix unambiguous syntax errors (closing brackets, removing trailing commas, converting Python literals). They do not change values, reorder keys, or make guesses about intent. If the repair tool finds something ambiguous, it will either leave it unchanged or explain the assumption it made.
Still dealing with broken JSON?
Paste it in and get it fixed in under 1 second — free, no signup, no install. Works with ChatGPT, Claude, n8n, and any AI output.
Fix My JSON Free →Related Articles