JSON Validator Online: Validate, Format, and Fix JSON in Your Browser
Validate JSON online instantly — no install, no account. Catch syntax errors, format for readability, and fix common mistakes with AI-powered repair.
Have broken JSON right now? Fix it free in under 1 second — no signup.
Fix My JSON →A JSON validator checks that your string is syntactically correct according to RFC 8259 — the standard that all parsers follow. If your JSON has a trailing comma, a single-quoted string, or an unquoted key, it will fail in any language's parser. A good online validator tells you exactly where and why.
How to Validate JSON Online
Paste your JSON into AI JSONMedic's validator and click Validate. You get:
- Valid — the JSON parses correctly and is safe to use
- Invalid — with the exact error position and a description of what's wrong
- Repaired — if you use the Fix button, common errors are corrected automatically and you see what changed
No account required. Your JSON never leaves your browser — it's validated client-side.
What JSON Validation Actually Checks
A validator runs JSON.parse() (or the equivalent in your language) and reports the result. The JSON spec requires:
- All strings in double quotes — single quotes are invalid
- All object keys in double quotes —
{name: "Alice"}is invalid - No trailing commas —
{"a": 1,}fails every parser - No comments —
// commentand/ comment /are not allowed - Boolean values as
true/false(lowercase) —True/Falsefrom Python fails - Null as
null— notNone, notundefined - No
NaNorInfinity— these are JavaScript values, not JSON
Every online validator checks the same spec. The difference between tools is how clearly they explain what failed and whether they can fix it.
Error Messages Explained
"Unexpected token"
The parser hit a character it didn't expect. Common causes:
// Trailing comma — parser expects } but finds ,
{"name": "Alice", "age": 30,}
// Single quote — parser sees ' and doesn't know what to do
{'name': 'Alice'}
// Unquoted key — parser expects " but sees n
{name: "Alice"}
The position number in the error points to the token that confused the parser, not always the typo itself. If the error says "position 42", look a few characters back.
"Unexpected end of JSON input"
The JSON is cut off. An opening bracket { or was never closed:
{"users": [{"name": "Alice"}, {"name": "Bob"
// ^ input ends here
This happens often with AI-generated JSON when the model hits its token limit mid-response.
"Duplicate key"
Some strict validators flag this. It's technically undefined behavior in the JSON spec — most parsers accept it and use the last value, but it's a sign of a bug.
{"id": 1, "id": 2} // which id is it?
JSON Validator vs JSON Formatter
These two terms are often conflated:
- Validator: checks if JSON is syntactically correct (pass/fail)
- Formatter: takes valid JSON and reformats it with consistent indentation and line breaks
Most online tools do both. You can't format invalid JSON, so the tool validates first. If it's valid, you get the formatted output. If it's invalid, you get an error.
Formatting (also called beautifying or pretty-printing) turns this:
{"name":"Alice","age":30,"address":{"city":"NYC","zip":"10001"}}
Into this:
{
"name": "Alice",
"age": 30,
"address": {
"city": "NYC",
"zip": "10001"
}
}
The [Format tool at AI JSONMedic handles this, including minification (the reverse — strip all whitespace for compact transmission).
Validating JSON in Code
For production code, you validate JSON by trying to parse it and catching the error:
JavaScript:function isValidJson(str) {
try {
JSON.parse(str);
return true;
} catch {
return false;
}
}
Python:import json
def is_valid_json(s):
try:
json.loads(s)
return True
except json.JSONDecodeError:
return False
TypeScript (with error details):function validateJson(str: string): { valid: boolean; error?: string } {
try {
JSON.parse(str);
return { valid: true };
} catch (e) {
return { valid: false, error: (e as SyntaxError).message };
}
}
Bash (using jq):if echo "$json_string" | jq empty 2>/dev/null; then
echo "valid"
else
echo "invalid"
fi
Validating JSON Against a Schema
Basic validation only checks syntax. Schema validation checks structure — whether the right fields exist with the right types. This catches semantic errors that syntax validation misses:
// Syntactically valid, but semantically wrong if age must be a number:
{"name": "Alice", "age": "thirty"}
JSON Schema is the standard for this. It lets you define rules like "age must be a positive integer" and "email is required". The JSON Schema guide on this site covers the full format with examples in JavaScript (Ajv), Python (jsonschema), and TypeScript (Zod).
For quick one-off schema checks, use Ajv in Node.js:
const Ajv = require('ajv');
const ajv = new Ajv();
const schema = {
type: 'object',
required: ['name', 'age'],
properties: {
name: { type: 'string' },
age: { type: 'integer', minimum: 0 }
}
};
const validate = ajv.compile(schema);
const valid = validate({ name: 'Alice', age: 30 });
if (!valid) console.log(validate.errors);
Common Scenarios Where JSON Fails Validation
Pasting from an AI chatbot
LLMs almost always wrap JSON in markdown code fences:
{"name": "Alice", "age": 30}
The backticks and json tag are markdown, not JSON. Any validator will reject this. Strip the fences before validating — or use AI JSONMedic which strips them automatically.
Copying from JavaScript source
JavaScript objects look like JSON but aren't:
// JavaScript object — NOT JSON
const user = {
name: 'Alice', // single quotes
active: true, // fine
score: NaN, // not valid JSON
// comment here // not valid JSON
}
The differences: single quotes, NaN, and comments all break JSON validation.
Truncated API response
If your API client has a response size limit or the server dropped the connection mid-stream, the JSON will be cut off. The validator will report "unexpected end of JSON input". The fix is to increase the response timeout or buffer size, not to manually close the brackets (unless you're doing one-off debugging).
Python repr() vs json.dumps()
Python's repr() on a dict gives you Python syntax, not JSON:
>>> repr({'name': 'Alice', 'active': True})
"{'name': 'Alice', 'active': True}"
# This is NOT valid JSON — single quotes, True
# Use json.dumps() instead:
>>> import json; json.dumps({'name': 'Alice', 'active': True})
'{"name": "Alice", "active": true}'
When to Use a Validator vs a Repair Tool
Use a validator when:
- You need a pass/fail check — "is this JSON safe to parse?"
- You're debugging your own code output
- You want to understand what specific rule was violated
Use a repair tool when:
- The JSON came from an AI model or LLM
- You got it from a Python script or JavaScript source
- You need it fixed, not just diagnosed
- It has multiple overlapping issues (e.g., trailing commas AND single quotes AND comments)
What Good Online Validators Have in Common
All JSON validators check the same spec, so the real differences are:
- Error precision — does it tell you the exact line and column, or just "invalid JSON"?
- Multi-error reporting — does it stop at the first error or show all issues?
- Repair capability — can it fix the errors, or only report them?
- Privacy — does the JSON get sent to a server, or validated in your browser?
- AI output handling — does it understand markdown fences, Python booleans, truncated structures?
For simple validation of hand-written JSON, JSONLint and similar tools work fine — see the AI JSONMedic vs JSONLint comparison for a side-by-side feature breakdown. For JSON from AI models, automated pipelines, or third-party APIs — where you need repair, not just diagnosis — AI JSONMedic's validator and repair tool are purpose-built for these cases.
Quick Error Reference
| Error message | Likely cause | Fix |
|---|---|---|
Unexpected token , | Trailing comma | Remove last comma before } or ] |
Unexpected token ' | Single quotes | Replace all ' with " |
| Unexpected token identifier | Unquoted key | Quote all keys with " |
| Unexpected end of input | Truncated JSON | Close all open brackets/braces |
Unexpected token T or F | Python True/False | Replace with true/false |
For any of these, paste the JSON into AI JSONMedic to get it repaired and explained in one step.
Validate JSON from the Command Line
If you prefer the terminal over a browser tool:
# jq — validate + pretty-print (install: brew install jq / apt install jq)
echo '{"name":"Alice"}' | jq '.'
# Python — validate only
echo '{"name":"Alice"}' | python3 -m json.tool
# Python — validate a file
python3 -m json.tool myfile.json
python3 -m json.tool is built into Python's standard library — no install required. It outputs the formatted JSON if valid, or a JSONDecodeError with line and column if invalid.
FAQ
What is the best free JSON validator online?
AI JSONMedic's JSON Validator stands out because it validates and repairs in one step — most validators only tell you something is wrong, not how to fix it. It supports JSON Schema validation, shows field-level error details, and processes everything client-side (your JSON never leaves your browser).
Does an online JSON validator send my data to a server?
It depends on the tool. AI JSONMedic's validator processes your JSON entirely in the browser using client-side JavaScript — nothing is sent to any server. Check the privacy policy or network tab for any tool you use with sensitive data. A tool that performs validation client-side will show no network requests when you paste and validate.
How do I validate JSON against a schema online?
Use a validator that supports JSON Schema — paste your JSON in the main input, then paste your schema in the Schema tab. The validator checks both syntax (is it valid JSON?) and structure (does it match the schema?). AI JSONMedic's validator supports JSON Schema Draft 7 and Draft 2020-12.
What is the difference between JSON validation and JSON formatting?
Validation checks whether the JSON is syntactically correct and optionally whether it matches a schema. Formatting (pretty-printing) takes valid JSON and adds indentation and line breaks to make it readable — it does not change the data. All formatters validate first (you can't format invalid JSON), but validators don't format.
How do I validate a large JSON file without a web tool?
Use command-line tools: Python's python3 -m json.tool file.json (built-in, no install), jq '.' file.json (validates and pretty-prints), or Node.js node -e "require('fs').readFileSync('file.json'); JSON.parse(...)". These handle files of any size without browser memory limits.
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