JSON Validator & Formatter

Check JSON syntax instantly. Get exact line and column for every error. Format valid JSON with one click. Free, no login, runs in your browser.

JSON Validator & Formatter

Input JSON

0 characters

Formatted JSON

0 characters

Options

Indentation

Error Details

Syntax Validation

Check JSON syntax instantly with exact line and column error reporting

Syntax Highlighting

Color-coded output distinguishes keys, strings, numbers, booleans, and nulls

Error Details

Error panel shows the exact line, position, and a plain-English fix tip

JSON Statistics

See size in bytes, nesting depth, and total element count for any valid JSON

JSON Validator Online — Check JSON Syntax Errors with Exact Line Numbers in 2026

When JSON is invalid, most error messages are frustrating. Your browser console says something like SyntaxError: Unexpected token } in JSON at position 247 and leaves you counting characters to figure out where line 247 even is. Or your server logs a parse error with no indication of which of a 300-line config file is broken. This JSON validator online gives you the actual line number and a plain-English explanation of what went wrong — which is almost always one of about six things.

Beyond validation, the tool also formats valid JSON with proper indentation and syntax highlighting, minifies it for production, and shows you stats like nesting depth and total element count. Everything runs locally in your browser — nothing is sent anywhere.

Keyboard shortcuts: Ctrl+Enter validates, Ctrl+F formats, Ctrl+M minifies. Useful when you're in a debugging flow and don't want to leave the keyboard.

The Six Most Common JSON Errors — What They Are and How to Fix Them

JSON parse errors almost always fall into a small set of categories. Once you recognize them, they become fast to fix:

Error Pattern What's Wrong How to Fix
{"name": "Alice" "age": 30} Missing comma between properties Add a comma after each value except the last one in an object
{"name": "Alice",} Trailing comma after last property Remove the comma after the last property before the closing brace
{'name': 'Alice'} Single quotes used instead of double quotes Replace all single quotes with double quotes for keys and string values
{name: "Alice"} Unquoted key Wrap all keys in double quotes: {"name": "Alice"}
// comment here Comments in JSON JSON has no comment syntax — remove all // and /* */ comments
{"value": undefined} undefined is not a JSON value Use null instead of undefined for missing values in JSON

The validator catches all of these and points to the exact location. When you see "Error at line 14" in the error panel, that's the line where the parser failed — the actual mistake is sometimes one or two lines earlier (for example, a missing comma on line 13 causes the error to show on line 14 where the next property starts).

Understanding the Validation Statistics

When validation passes, the stats panel shows four values. Here's what they actually mean and why they're useful:

Size (bytes) is the size of the minified JSON — the JSON string with all whitespace removed. This is the actual payload size when you transmit or store JSON. It's different from the formatted version size, which includes all the indentation spaces. If you're checking whether a JSON payload is within an API's size limit, this is the number to look at.

Depth level is the maximum nesting depth. A flat object has depth 1. An object with an array of objects has depth 3. Deeply nested structures (depth 8+) can be a design smell — they make the data harder to work with, slower to parse, and more error-prone to traverse in code. If you see a depth of 12, it's worth asking whether the structure could be flatter.

Total elements counts every value in the JSON — each primitive value, each array, each object. This gives you a sense of the data volume. A JSON with 3 items but 1,200 elements has very nested or large array structures inside those items.

Auto-Validate vs Manual Validation — When to Use Each

The "Auto-validate on input" option runs validation every time you type or paste into the input area. This is useful when you're building up a JSON string incrementally and want instant feedback. The downside is that it fires on every keystroke, which means you see errors on incomplete input — like an error while you're in the middle of typing a string value.

For most use cases — pasting an API response, checking a config file, debugging a specific error — you'll paste the full JSON and then want a single validation run. In that case, auto-validate is fine because the paste happens in one operation and validation runs once.

Turn auto-validate off when you're manually editing JSON in the input area and don't want the error panel jumping in while you're mid-edit. Click Validate manually when you're done.

Syntax Highlighting — What Each Color Means

The formatted output area uses color-coding to make JSON structure more readable at a glance. The color scheme follows the Solarized theme, which is widely used in code editors:

This color scheme makes it immediately obvious when a value is the wrong type. If a field should be a number but shows up teal (quoted string), you can see that at a glance without reading the value carefully. If a field should be a string but shows blue (number), same thing.

JSON Validation vs JSON Schema Validation

This tool validates JSON syntax — it checks that the text is valid JSON according to the JSON specification (RFC 8259). That means checking brackets match, commas are in the right places, keys are quoted, values are valid types, and so on.

JSON Schema validation is a different and additional layer. It checks not just that the JSON is syntactically valid, but that it has the right structure for a specific purpose — that an API request has the required fields, that a number field is within a certain range, that a string matches a specific pattern. This tool doesn't do schema validation, but the JSON formatter tool on this platform does support schema-based validation if you need that layer of checking.

For most debugging scenarios — "why is this API call failing," "why is my config file not loading," "did I type this correctly" — syntax validation is all you need. Schema validation is for enforcing contracts between systems.

When JSON Looks Valid But Still Fails — Edge Cases Worth Knowing

Occasionally JSON passes syntax validation but still causes problems in specific contexts. A few edge cases worth being aware of:

Frequently Asked Questions

What does "Unexpected token" mean in a JSON error?

"Unexpected token" means the JSON parser encountered a character it didn't expect at that position. The most common causes: a missing comma (the parser hit the next key when it expected a comma or closing brace), a trailing comma (the parser hit a closing brace after a comma when it expected another value), or wrong quote type (single quote when double quote is required). The line and column number in the error panel tells you exactly where the unexpected character is. The actual mistake is usually on the line just before the error location.

Why does my JSON pass validation here but fail in my application?

This usually means the issue isn't JSON syntax but JSON schema — the structure is valid JSON but doesn't match what your application expects. For example, a required field is missing, a number is being sent as a string, or an array is empty when the app expects at least one item. Syntax validation (what this tool does) can't catch those issues. Check your application's error message carefully — if it says something like "field X is required" or "expected string, got number," that's a schema/contract issue, not a syntax issue.

Can I validate JSON that has JavaScript-style comments?

Standard JSON doesn't support comments. If your JSON has // ... or /* ... */ comments, it will fail validation because those characters are invalid in JSON syntax. What you actually have is JSONC (JSON with Comments) or JSON5, which are supersets used in tools like VS Code's settings files. To validate it as standard JSON, remove the comments first. If you need to keep comments, check whether the system consuming your JSON accepts JSONC or JSON5 format.

What does the depth level stat tell me?

Depth level is the maximum nesting depth — how many levels of objects and arrays inside other objects and arrays. Depth 1 is a flat object. Depth 3 means objects inside arrays inside objects, or similar three-level nesting. Very high depth (8+) can make JSON harder to traverse in code and slower to parse. It's also often a sign that the data structure could be redesigned to be flatter. For most API responses and config files, depth under 5 is typical.

Is my JSON data safe to paste into this validator?

Yes. All validation processing runs locally in your browser using JavaScript. Nothing you paste is transmitted to any server — the validation, formatting, and statistics all execute on your machine. You can safely paste JSON containing API keys, user data, internal configuration, credentials, or any sensitive information. Once you close the tab, nothing is retained. There's no account, no logging, and no external network requests involving your data.

What's the difference between the JSON Validator and the JSON Formatter tools on this site?

This validator tool emphasizes the validation and error-finding experience — the error details panel, line number reporting, and statistics are front and center. The JSON Formatter tool on this platform is optimized for the formatting and transformation workflow — sort keys, escape Unicode, choose indentation, minify. Both validate JSON, both format JSON. If your primary task is "is this JSON valid and where is the error," this tool is more focused. If your primary task is "take this valid JSON and transform or format it a specific way," the formatter tool has more options.

Using the Validator as Part of an API Debugging Workflow

Here's a practical workflow that covers most JSON debugging situations:

The stats panel after successful validation is a bonus — it gives you a quick sense of the JSON's structure (how deep, how many elements, how big) which is useful context when you're trying to understand an unfamiliar API response or data structure for the first time.