Paste JSON and click Validate
or press Ctrl+Enter / ⌘Enter
Definition
What is a JSON Validator?
A JSON Validator (also called a JSON syntax checker or JSON linter) checks whether a JSON string conforms to RFC 8259 — the official JSON specification. It identifies every JSON syntax error — trailing commas, unquoted keys, single quotes, missing brackets — and reports the exact line and character position, so you can fix invalid JSON in seconds instead of hunting through hundreds of lines manually.
What is JSON Validation?
JSON validation — also called JSON linting or JSON syntax checking — is the process of verifying a JSON string against the RFC 8259 specification. A JSON checker parses every bracket, comma, quote, and data type and flags anything that violates the standard. When it finds a JSON syntax error it reports the exact position so you can fix it immediately — without scanning hundreds of lines manually.
This is distinct from formatting: a JSON formatter makes valid JSON human-readable by adding indentation. A validator tells you whether your JSON is valid in the first place. Always validate first, then format.
JSON Validation Rules — RFC 8259
The JSON specification (RFC 8259) defines six hard rules. Violating any one of them produces a syntax error that prevents parsing.
A JSON value must be one of six types
object {}, array [], string "", number, boolean (true/false), or null. No other types are allowed.
Invalid
{"fn": function(){}}Valid
{"fn": null}Object keys must be double-quoted strings
Every key in a JSON object must be a string surrounded by double quotes. Unquoted identifiers and single-quoted strings are not valid.
Invalid
{name: "Alice"}Valid
{"name": "Alice"}All strings must use double quotes
Single quotes are not part of the JSON specification. This applies to both keys and string values.
Invalid
{'name': 'Alice'}Valid
{"name": "Alice"}Numbers cannot have leading zeros
01, 007, 0123 are all invalid. The only number starting with 0 is 0 itself, or a decimal like 0.5.
Invalid
{"code": 007}Valid
{"code": 7}No trailing commas
A comma after the last element in an object or array is a syntax error. JSON is stricter than JavaScript object literals here.
Invalid
{"a": 1, "b": 2,}Valid
{"a": 1, "b": 2}No comments of any kind
// single-line and /* */ block comments are JavaScript syntax. They are not part of RFC 8259 and will cause a parse error.
Invalid
{"name": "Alice" // user}Valid
{"name": "Alice"}Why JSON Validation Matters
Prevents Runtime Crashes
A single trailing comma in an API response or config file can throw an uncaught SyntaxError and crash your entire application. Catch it here before it reaches production.
Faster Debugging
Browser errors say "Unexpected token at position 284" — meaningless without context. This validator pinpoints the exact line and character so you can fix it in seconds.
Safer Data Pipelines
Validate JSON exports before ingesting them into MongoDB, Elasticsearch, or an ETL pipeline. One malformed record in a batch job can corrupt downstream data or fail the entire run.
Features of This JSON Validator
- my_locationPrecise error location — reports the exact line number and character position of every syntax error.
- boltAuto-validate on paste — paste JSON and the validator runs immediately, no button click needed.
- lock100% client-side — your JSON never leaves the browser. Safe for API keys, tokens, and sensitive payloads.
- analyticsStructure analysis — on valid JSON shows type, total key count, nesting depth, and top-level item count.
- keyboardKeyboard shortcut — press Ctrl+Enter (or Cmd+Enter on Mac) to validate without reaching for the mouse.
- volunteer_activismCompletely free — no account, no rate limits, no paywalls. Use it as many times as needed.
JSON Validator Example
Here is what valid vs invalid output looks like when you paste JSON into the validator above:
Invalid — Trailing Comma
{"name": "John", "age": 30,}✗ SyntaxError: Unexpected token } in JSON at position 27
Valid JSON
{"name": "John", "age": 30}✓ Valid · Type: Object · Top Keys: 2 · Depth: 1
How to Validate JSON Online — Step by Step
1. Paste your JSON
Copy your JSON string — from an API response, config file, webhook payload, or database export — and paste it into the Input JSON box. The validator auto-checks on paste.
2. Click Validate (or press Ctrl+Enter)
Press the Validate button or use the Ctrl+Enter keyboard shortcut. The JSON checker runs instantly in your browser using the native JSON parser — no server, no delay.
3. Fix errors and re-validate
If invalid: the exact error message and position are shown, plus a quick-fix checklist. Edit the input, then validate again. Repeat until you see the green "Valid JSON" result.
4. Deploy with confidence
Once the result shows "Valid JSON", your JSON is RFC 8259 compliant and safe to use in APIs, config files, databases, and data pipelines. No more silent parse failures.
JSON Validator vs Formatter vs Linter
These tools are related but solve different problems. The typical workflow is: validate → fix errors → format.
| Tool | Primary Purpose | Output | Best For |
|---|---|---|---|
| JSON Validator / LinterThis tool | Check syntax correctness | Pass / fail + exact error position | Catching syntax errors before deploying |
| JSON Formatter | Beautify / pretty-print | Indented, human-readable JSON | Making minified JSON readable |
| JSON Schema Validator | Validate types & structure | Schema conformance report | Checking values match expected types |
| JSON Editor | Browse and edit JSON | Editable tree / raw editor | Interactive editing of JSON documents |
JSON Schema Validation vs Syntax Validation
There are two distinct levels of JSON validation that developers often confuse:
Syntax Validation (this tool)
Checks whether the JSON text is well-formed — correct brackets, commas, quotes, and data types. This is what JSON.parse() does in every language. A syntax validator answers: “Is this valid JSON?”
// Always valid syntax:
{"age": "thirty"} // ✓ well-formed
{"age": 30} // ✓ well-formedJSON Schema Validation
Validates values against a JSON Schema definition (draft-07, draft-2020-12). It answers: “Does this JSON match the expected structure and types?” Tools like Ajv implement this. Useful for API contract testing and input validation in applications.
// Schema says age must be number:
{"age": "thirty"} // ✗ type mismatch
{"age": 30} // ✓ matches schemaUse this tool for syntax validation. For schema-level type checking, integrate Ajv or a JSON Schema validator into your build pipeline.
Common JSON Errors & How to Fix Them
These five errors account for the vast majority of invalid JSON. Paste your JSON into the validator to detect them automatically.
Trailing comma
The most common error. JSON does not allow a comma after the last element in an object or array. JavaScript objects allow it — JSON does not.
Invalid
{"name": "Alice", "age": 30,}Valid
{"name": "Alice", "age": 30}Unquoted keys
All object keys must be wrapped in double quotes. Single quotes and bare identifiers (like JavaScript object keys) are invalid JSON.
Invalid
{name: "Alice", age: 30}Valid
{"name": "Alice", "age": 30}Single-quoted strings
JSON requires double quotes for all strings — both keys and values. Single quotes are only valid in JavaScript, not in the JSON specification.
Invalid
{'name': 'Alice'}Valid
{"name": "Alice"}undefined / NaN / Infinity
JSON only supports null for absence of value. undefined, NaN, and Infinity are JavaScript-specific primitives that have no JSON equivalent.
Invalid
{"value": undefined, "score": NaN}Valid
{"value": null, "score": null}Comments in JSON
Standard JSON does not support comments. Use JSON5 or JSONC format (used by TypeScript and VS Code) if you need comments — or strip them before parsing.
Invalid
{"name": "Alice" // user name
}Valid
{"name": "Alice"
}JSON Error Messages Decoded
Every JSON.parse() error message tells you exactly what went wrong — if you know how to read it. Here is a reference for the most common JSON parse errors:
| Error Message | Likely Cause | Fix |
|---|---|---|
| Unexpected token } | Trailing comma before closing brace | Remove the comma before } |
| Unexpected token ] | Trailing comma before closing bracket | Remove the comma before ] |
| Unexpected token ' | Single quotes used instead of double | Replace ' with " for all strings |
| Unexpected end of JSON input | Missing closing } or ] — JSON is truncated | Add the missing closing bracket or brace |
| Unexpected token [a-z identifier] | Unquoted object key or JavaScript keyword | Wrap the key in double quotes |
| Unexpected token , | Double comma (,,) or comma after opening brace | Remove the extra comma or missing value |
| Unexpected token / | // or /* comment in the JSON | Remove all comments from the JSON text |
| Unexpected non-whitespace character after JSON | Extra content after the closing } or ] | Remove everything after the final closing bracket |
Paste your JSON above and the validator will show you the exact error message — then match it to this table to find the fix instantly.
API Response Validation Workflow
One of the most common uses of a JSON validator is validating API responses. Malformed JSON from a third-party API causes silent failures and 500 errors that are notoriously hard to debug. Here is a bulletproof workflow:
Copy the raw API response
In your browser DevTools (Network tab) or Postman, copy the raw response body. Do not let your HTTP client auto-parse it — you want the raw string.
// Or capture it in code before parsing: const raw = await response.text(); // NOT response.json() console.log(raw); // paste this into the validator
Paste into the validator and check
Paste the raw string here. If the validator shows "Valid JSON", your API is returning well-formed JSON and the bug is elsewhere (wrong field name, null value, etc.). If it shows an error, you have a malformed response.
Identify and debug the source
A JSON syntax error in an API response means the server is returning malformed data. Common causes: server-side exception leaking HTML into the response body, Content-Type mismatch, or a middleware truncating the payload.
// Check the Content-Type header:
fetch('/api/data')
.then(r => { console.log(r.headers.get('content-type')); return r.text(); })
.then(raw => console.log(raw.slice(0, 200))); // log first 200 charsAdd validation to your production code
Once you understand the pattern, add a try/catch around every JSON.parse() call in production. Never assume a third-party API always returns valid JSON.
async function safeJsonFetch(url: string) {
const res = await fetch(url);
const text = await res.text();
try {
return JSON.parse(text);
} catch {
throw new Error(`Invalid JSON from ${url}: ${text.slice(0, 100)}`);
}
}Validate JSON in Your Language
Every major language has a built-in JSON parser that throws on invalid input. Use these snippets to validate JSON programmatically — or use this tool for a faster interactive check.
try {
const data = JSON.parse(jsonString);
console.log('Valid JSON:', data);
} catch (e) {
console.error('Invalid JSON:', e.message);
}import json
try:
data = json.loads(json_string)
print('Valid JSON:', data)
except json.JSONDecodeError as e:
print('Invalid JSON:', e)import "encoding/json"
var result interface{}
if err := json.Unmarshal([]byte(jsonStr), &result); err != nil {
fmt.Println("Invalid JSON:", err)
}# Validate a JSON file from the terminal
node -e "JSON.parse(require('fs').readFileSync('file.json','utf8')); console.log('Valid')"# Validate a JSON file using Python's built-in tool python3 -m json.tool file.json > /dev/null && echo "Valid"
JSON5, JSONC & Comments in JSON
Standard JSON does not support comments, trailing commas, or unquoted keys. If your file has these features, it is one of these extended formats:
JSON
RFC 8259- checkDouble-quoted keys & strings
- checkNo trailing commas
- checkNo comments
- checkNo Infinity / NaN
The standard. Used by all REST APIs and data exchanges.
JSON5
json5.org- checkUnquoted keys allowed
- checkSingle quotes allowed
- checkTrailing commas OK
- check// and /* */ comments
Superset of JSON. Used in some config files. Not valid standard JSON.
JSONC
JSON with Comments- checkStandard JSON + comments
- check// and /* */ comments
- checkUsed by VS Code & TypeScript
- checktsconfig.json, .eslintrc
Strip comments before parsing with a standard JSON.parse().
Rule of thumb: if a file is consumed by an API or JSON.parse(), it must be valid standard JSON. If it's a developer-facing config file (tsconfig, .eslintrc, VS Code settings), JSONC or JSON5 may be acceptable depending on the tool.
Validate JSON in CI/CD Pipelines
Automate JSON validation in your build pipeline to catch errors before they reach production. A failed JSON parse in a CI check is infinitely cheaper than a production 500 error.
- name: Validate JSON files
run: |
for f in **/*.json; do
python3 -m json.tool "$f" > /dev/null && echo "✓ $f"
done"scripts": {
"validate:json": "node -e \"['config.json','data.json'].forEach(f => { JSON.parse(require('fs').readFileSync(f)); console.log('✓', f); })\""
}# jq is the fastest JSON validator in shell scripts cat api-response.json | jq . > /dev/null && echo "Valid" || echo "Invalid"
Frequently Asked Questions
What is a JSON validator?expand_more
What is the most common JSON syntax error?expand_more
What is the difference between valid and well-formed JSON?expand_more
Can I validate JSON with comments?expand_more
Does validating JSON check data types against a schema?expand_more
Why does my JSON fail in code but pass the validator?expand_more
Can I validate large JSON files?expand_more
What is the difference between a JSON validator and a JSON linter?expand_more
Developer Insights
From the Blog
JSON Validator Guide: How to Find and Fix Every Syntax Error
A step-by-step walkthrough of every common JSON syntax error — trailing commas, unquoted keys, single quotes — and how to fix them fast.
Why You Should Validate JSON Before Every Deploy
How one trailing comma in a config file caused a 2-hour production outage — and the CI/CD check that would have caught it in 200ms.
Debugging JSON.parse Errors: A Complete Reference
Every SyntaxError JSON.parse throws, what each message means, and how to fix the underlying problem in your code or data source.
Part of the JSON Toolkit
Explore All JSON Tools
Free online tools for every JSON task — format, validate, convert, compare, and more.