JSON Validator Online

1234567891011121314151617181920
shield_check

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.

shieldRuns entirely in your browser
cloud_offNo data stored or uploaded
boltAuto-validates on paste
volunteer_activismFree forever

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.

1

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}
2

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"}
3

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"}
4

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}
5

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}
6

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

api

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.

bug_report

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.

storage

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:

cancel

Invalid — Trailing Comma

{"name": "John", "age": 30,}

✗ SyntaxError: Unexpected token } in JSON at position 27

check_circle

Valid JSON

{"name": "John", "age": 30}

✓ Valid · Type: Object · Top Keys: 2 · Depth: 1

How to Validate JSON Online — Step by Step

content_paste

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.

check_circle

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.

build

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.

rocket_launch

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.

ToolPrimary PurposeOutputBest For
JSON Validator / LinterThis toolCheck syntax correctnessPass / fail + exact error positionCatching syntax errors before deploying
JSON FormatterBeautify / pretty-printIndented, human-readable JSONMaking minified JSON readable
JSON Schema ValidatorValidate types & structureSchema conformance reportChecking values match expected types
JSON EditorBrowse and edit JSONEditable tree / raw editorInteractive editing of JSON documents

JSON Schema Validation vs Syntax Validation

There are two distinct levels of JSON validation that developers often confuse:

code

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-formed
schema

JSON 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 schema

Use 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.

error

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}
error

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}
error

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"}
error

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}
error

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 MessageLikely CauseFix
Unexpected token }Trailing comma before closing braceRemove the comma before }
Unexpected token ]Trailing comma before closing bracketRemove the comma before ]
Unexpected token 'Single quotes used instead of doubleReplace ' with " for all strings
Unexpected end of JSON inputMissing closing } or ] — JSON is truncatedAdd the missing closing bracket or brace
Unexpected token [a-z identifier]Unquoted object key or JavaScript keywordWrap the key in double quotes
Unexpected token ,Double comma (,,) or comma after opening braceRemove the extra comma or missing value
Unexpected token /// or /* comment in the JSONRemove all comments from the JSON text
Unexpected non-whitespace character after JSONExtra 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:

01

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
02

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.

03

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 chars
04

Add 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.

JavaScript / Node.js
try {
  const data = JSON.parse(jsonString);
  console.log('Valid JSON:', data);
} catch (e) {
  console.error('Invalid JSON:', e.message);
}
Python
import json
try:
    data = json.loads(json_string)
    print('Valid JSON:', data)
except json.JSONDecodeError as e:
    print('Invalid JSON:', e)
Go
import "encoding/json"

var result interface{}
if err := json.Unmarshal([]byte(jsonStr), &result); err != nil {
    fmt.Println("Invalid JSON:", err)
}
CLI (Node.js)
# Validate a JSON file from the terminal
node -e "JSON.parse(require('fs').readFileSync('file.json','utf8')); console.log('Valid')"
CLI (Python)
# 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.

GitHub Actions
- name: Validate JSON files
  run: |
    for f in **/*.json; do
      python3 -m json.tool "$f" > /dev/null && echo "✓ $f"
    done
npm script (package.json)
"scripts": {
  "validate:json": "node -e \"['config.json','data.json'].forEach(f => { JSON.parse(require('fs').readFileSync(f)); console.log('✓', f); })\""
}
Shell (jq)
# 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
A JSON validator checks whether a JSON string conforms to RFC 8259. It identifies syntax errors such as trailing commas, unquoted keys, single-quoted strings, and unclosed brackets, reporting the exact line and character position of each error.
What is the most common JSON syntax error?expand_more
Trailing commas after the last element in an array or object are the most common error. Standard JSON does not allow them, unlike JavaScript object literals or JSON5. Remove the trailing comma and revalidate.
What is the difference between valid and well-formed JSON?expand_more
In JSON, "valid" and "well-formed" mean the same thing — the text conforms to the JSON grammar. Unlike XML, JSON has no separate schema validation at the syntax level.
Can I validate JSON with comments?expand_more
Standard JSON does not support comments. If your file has // or /* */ comments, it is JSON5 or JSONC format. Remove comments before validating, or use a JSON5 parser for those files.
Does validating JSON check data types against a schema?expand_more
No. Syntax validation only confirms the JSON is structurally well-formed. It does not check whether values match an expected schema (e.g. that "age" is a number). Use JSON Schema validation with tools like Ajv for type-level checking.
Why does my JSON fail in code but pass the validator?expand_more
This usually means your application receives a different string than what you pasted. Common causes: BOM characters at the start of the file, invisible Unicode characters, encoding issues (UTF-16 vs UTF-8), or a missing Content-Type: application/json header.
Can I validate large JSON files?expand_more
Yes. Because validation is entirely client-side, there is no server-side file size limit. Large JSON validates instantly on modern hardware — performance depends on your browser and device.
What is the difference between a JSON validator and a JSON linter?expand_more
The terms are used interchangeably for syntax validation. Technically, a linter can also enforce style rules (key ordering, indentation), but for most developers "JSON linter" and "JSON validator" both mean: check that the JSON is syntactically correct.
JSON Validator Online — Find & Fix JSON Syntax Errors