ToolDeck

اعتبارسنجی JSON

اعتبارسنجی سینتکس و ساختار JSON

یک مثال امتحان کنید
به‌صورت محلی اجرا می‌شود · جای‌گذاری اسرار امن است

What is JSON Validation?

JSON validation is the process of checking whether a string of text conforms to the JSON specification. A valid JSON document has correct syntax: properly quoted strings, no trailing commas, no comments, and a single root element. Validation tells you immediately whether your JSON can be parsed — and if not, exactly where the problem is.

Valid JSON
json
{
  "user": "alice",
  "age": 30,
  "active": true,
  "tags": ["admin", "editor"]
}
Invalid JSON — trailing comma
json
{
  "user": "alice",
  "age": 30,
}

Why Validate JSON?

Invalid JSON silently breaks APIs, configuration loaders, and data pipelines. A single misplaced comma can prevent an entire application from starting. Catching these errors at development time — not in production — is the difference between a smooth release and an outage.

📍
Pinpoint Error Location
The validator not only tells you that JSON is invalid but identifies the exact line and column where the error occurs, so you can jump straight to the problem.
Validate as You Type
Real-time validation provides instant feedback as you edit. You see errors disappear as you fix them — no need to click a button or wait for a build.
🔍
Distinguish Syntax from Logic
JSON validation catches syntax errors only. It confirms the document is parseable, separate from whether the values are semantically correct for your application.
🔒
Private by Design
All validation runs in your browser. Credentials, API keys, and sensitive payloads are never sent to a server.

Common JSON Validation Errors

These four mistakes account for the vast majority of JSON validation failures:

Trailing Comma
A comma after the last item in an object or array. Valid in JavaScript but strictly forbidden in JSON.
json
{ "a": 1, "b": 2, }
Single-Quoted Strings
Single quotes are not valid in JSON. Both keys and values must use double quotes.
json
{ 'key': 'value' }
Undefined and NaN
undefined, NaN, and Infinity are JavaScript values but not valid JSON. Use null or a numeric string instead.
json
{ "val": undefined }
Unquoted Keys
JSON requires all object keys to be strings in double quotes. Bare identifiers like in JavaScript objects are not allowed.
json
{ key: "value" }

Common Use Cases

API Contract Verification
Validate request and response bodies against expected shapes to catch integration bugs before they reach production.
Configuration File QA
Validate package.json, tsconfig.json, and other config files before committing to ensure they parse correctly.
Data Pipeline Validation
Check that data ingested from external sources or user uploads is syntactically sound before processing.
CI/CD Pre-flight Check
Run JSON validation as a build step to prevent invalid configuration files from being deployed.
Learning and Debugging
Use the validator as a learning tool to understand why specific JSON syntax patterns are or aren't valid.
Generated JSON QA
Verify that JSON produced by code generators, templates, or serializers is correctly formed before use.

Frequently Asked Questions

What is the difference between JSON validation and JSON Schema validation?
JSON validation (what this tool does) checks syntax — whether the document is parseable JSON. JSON Schema validation is a separate step that checks whether the values conform to a defined structure, types, and constraints.
Is JSON5 or JSONC valid JSON?
No. JSON5 (allows single quotes, comments, trailing commas) and JSONC (allows comments) are supersets of JSON but not valid standard JSON. This tool validates against the strict JSON specification (RFC 8259).
Why does my JSON fail to parse even though it looks correct?
The most common invisible culprits are: a trailing comma after the last property, a byte-order mark (BOM) at the start of the file, or a single-quoted string. Paste your JSON into the validator to pinpoint the exact location.
Can JSON contain comments?
No — the JSON specification (RFC 8259) explicitly forbids comments. If you need comments in configuration files, use JSONC or JSON5 locally, then strip comments before serializing.
What is a valid JSON root value?
هر مقدار JSON می‌تواند ریشه باشد: یک شیء {}, یک آرایه []، یک رشته، یک عدد، true، false، یا null. در عمل اکثر API‌ها از یک شیء یا آرایه در ریشه استفاده می‌کنند، اما هر شش نوع از نظر نحوی معتبر هستند.