JSON Validator

Paste any JSON document and instantly see whether it's valid, with the exact line and column of the first syntax error and summary statistics for valid input. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-18

Overview

Introduction

Not everything that looks like JSON is valid JSON. A stray trailing comma or a JavaScript-style single-quoted string will make a strict parser reject the whole document, even though the same text works fine as a JavaScript object literal. This validator tells you immediately whether your input conforms to the JSON specification, and exactly where it breaks if it doesn't.

It exists because the error messages you get from validating JSON deep inside an application, a build tool, or an API client are often unhelpful. A generic 'unexpected token' with no context, or a failure several layers removed from the actual malformed input. Checking the raw document directly, before it enters any pipeline, gives you a precise answer immediately instead of an obscure one downstream. The tool runs the same JSON grammar defined in RFC 8259 and ECMA-404, the two interoperable standards that define JSON, so a pass here means your document is JSON in the strict, portable sense, not just JSON-like.

What Is JSON Validator?

A JSON validator is a tool that attempts to parse a document against the JSON specification and reports success or the precise location of the first syntax error. This one uses your browser's native, ECMAScript-standard JSON.parse() implementation directly, the exact function every JavaScript runtime uses internally. A document that passes here will parse identically in Node.js, in a browser, or in any spec-compliant JSON library.

It deliberately checks syntax only, not meaning. A document can be perfectly valid JSON and still be missing a required field or have a value of the wrong type for your application. That's a separate concern, handled by schema validation against a JSON Schema document, and keeping the two apart is what makes this tool fast and its results unambiguous. Short version: a validator answers 'does this parse?' A schema validator answers 'does this parse, and does it also match my rules?'

There's also a distinction worth drawing between a validator and a parser, even though this tool is built directly on top of one. A parser's job is to convert text into an in-memory data structure, or throw trying. It's a building block used inside applications, not a diagnostic tool. A validator wraps that parser specifically to answer a yes/no question for a human, with a readable error location instead of an uncaught exception. This tool never leaves your device to do that work. Because it runs entirely client-side with no server round trip, the parsing happens in milliseconds and no data leaves the browser tab, which also makes it safe to use on sensitive or unpublished payloads. A server-side validation step, by contrast, is only necessary once JSON is being consumed by a backend that needs to reject bad input at a trust boundary. This tool is for the earlier stage, catching the mistake before it ever reaches that boundary.

How JSON Validator Works

The validator runs your input through the browser's native, spec-compliant JSON parser, encoded and measured as UTF-8 for the byte-size statistic. On success it also computes lightweight statistics: top-level type, nesting depth, key or item count, byte size. On failure it parses the parser's error message to extract a line and column so you can jump straight to the problem.

Different JavaScript engines phrase parse errors differently. Some, V8, used by Chrome and Node.js, report a raw zero-indexed character position; others report a line and column directly. The tool normalizes both formats into a single, consistent 1-indexed line/column result. That's what lets the reported location stay reliable regardless of which browser or environment produced the underlying error message, so the position you see here points at the same character whether you're using Chrome, Firefox, or Safari.

When To Use JSON Validator

Use it before feeding JSON into a script, API, or config loader that will fail with a less helpful error message. It's also useful when debugging a hand-edited config file or checking output copied from an unreliable source like a chat log or PDF.

Run it as a quick sanity check too, whenever JSON has passed through a manual step, a copy-paste, a text-based diff merge, or a template substitution — any of those can silently introduce a broken comma or an unescaped character that only a real parse will catch.

Features

Advantages

  • Pinpoints the exact line and column of the first syntax error.
  • Reports structural statistics (depth, key count, size) for valid documents.
  • Runs fully offline in the browser, so no data leaves your machine.
  • Uses the same parser your JavaScript runtime uses, so results match production behavior.

Limitations

  • Validates syntax only, not semantic correctness against a schema or business rules.
  • Only reports the first error encountered; documents with multiple errors need to be fixed one at a time.
  • Does not support JSON5 or JSONC (comments, trailing commas, unquoted keys) by design, since it checks strict JSON.

Syntax Validation vs. Schema Validation

Syntax Validation vs. Schema Validation
Syntax validator (this tool)Schema validator (e.g. Ajv)
Checks the document parses as valid JSONYesYes, as a prerequisite
Checks specific fields have the right typeNoYes
Checks required fields are presentNoYes
Needs a schema written firstNoYes
Best forQuick syntax checks on any JSONEnforcing a contract on API payloads

Examples

Missing comma between properties

Invalid input

{"a": 1 "b": 2}

Parser error

SyntaxError: Expected ',' or '}' after property value in JSON at position 8 (line 1, column 9)

Every property in a JSON object must be separated from the next by a comma. Here the parser reaches the end of "a"'s value and, instead of a comma or a closing brace, finds the start of another key, so it stops.

Corrected version

{"a": 1, "b": 2}

Trailing comma after the last property

Invalid input

{"a": 1, "b": 2,}

Parser error

SyntaxError: Expected double-quoted property name in JSON at position 16 (line 1, column 17)

Standard JSON doesn't allow a comma after the last property in an object or the last item in an array, unlike JavaScript object literals, which permit it. The parser expects another quoted key after the comma and finds the closing brace instead.

Corrected version

{"a": 1, "b": 2}

Unquoted (missing-quote) object key

Invalid input

{"a": 1, b: 2}

Parser error

SyntaxError: Expected double-quoted property name in JSON at position 9 (line 1, column 10)

JSON requires every object key to be a double-quoted string, with no exceptions. Unquoted keys are valid in JavaScript object literals but not in JSON, which is a common source of confusion when copying code instead of data.

Corrected version

{"a": 1, "b": 2}

Unexpected token from concatenated documents

Invalid input

{"a": 1}{"b": 2}

Parser error

SyntaxError: Unexpected non-whitespace character after JSON at position 8 (line 1, column 9)

A JSON document must contain exactly one top-level value. Pasting two objects back to back, common when copying from newline-delimited JSON (NDJSON) or concatenated log output, leaves trailing characters the parser doesn't expect after the first valid value ends.

Corrected version

[{"a": 1}, {"b": 2}]

Duplicate object keys (valid, but silent)

Invalid input

{"id": 1, "name": "Ada", "id": 2}

Parser error

Valid JSON. Parses to { "id": 2, "name": "Ada" }; the second "id" silently overwrites the first.

Duplicate keys aren't a syntax error under RFC 8259, so this one passes validation. But JSON.parse() keeps only the last value for a repeated key and silently discards the earlier one, which can hide a real bug that no validator will ever flag as invalid.

Corrected version

{"id": 2, "name": "Ada"}

Invalid escape character

Invalid input

{"path": "C:\Users\dev"}

Parser error

SyntaxError: Bad escaped character in JSON at position 13 (line 1, column 14)

Inside a JSON string, a backslash must begin one of a fixed set of escape sequences (\", \\, \/, \b, \f, \n, \r, \t, or \uXXXX). A bare backslash before an ordinary letter, common in Windows file paths, isn't valid and has to be escaped itself.

Corrected version

{"path": "C:\\Users\\dev"}

Bad Unicode escape sequence

Invalid input

{"char": "\u12G4"}

Parser error

SyntaxError: Bad Unicode escape in JSON at position 14 (line 1, column 15)

A \u escape must be followed by exactly four hexadecimal digits (0–9, a–f, A–F). "G" isn't a valid hex digit, so the parser can't resolve the escape into a UTF-8 code point.

Corrected version

{"char": "\u1234"}

Trailing comma inside a nested array

Invalid input

{"user": {"name": "Ana", "roles": ["admin", "editor",]}}

Parser error

SyntaxError: Unexpected token ']' in JSON at position 56 (line 1, column 57)

The same trailing-comma rule applies at every nesting level, not just the outermost object. Here the outer object and inner object are both fine, the error comes from the comma left after the last string in the nested "roles" array.

Corrected version

{"user": {"name": "Ana", "roles": ["admin", "editor"]}}

Best Practices & Notes

Best Practices

  • Validate JSON as a pre-commit or CI step for config files that are hand-edited, since a broken config caught locally is far cheaper than one that fails a deploy or a build pipeline.
  • When copying JSON from documentation, an LLM response, or a chat tool, validate before pasting it into production config. Those sources frequently introduce smart quotes or JavaScript-style trailing commas that look identical to valid JSON at a glance.
  • Combine with the JSON Schema Generator when you also need to check structure, not just syntax: validate first to rule out parse errors, then run a schema validator to check field types and required keys.
  • Treat duplicate keys as a linting concern even though they're not a syntax error. A document with a repeated key is technically valid JSON but almost always represents a mistake in how it was generated.
  • When debugging a large, deeply nested payload, validate progressively smaller sub-sections (a single object, a single array) rather than the whole document, since the first reported error position is the only one shown and later errors stay hidden until the first is fixed.
  • Re-run validation after every manual edit to a config file, not just once at the end. Each hand edit is an opportunity to introduce exactly the kind of single-character mistake (a missing comma, an unescaped backslash) this tool exists to catch.

Developer Notes

Error messages come directly from the JavaScript engine's native JSON.parse() implementation, using the same ECMAScript-specified JSON grammar every browser is required to implement, so error wording differs slightly between engines even though the underlying grammar they enforce is identical. V8 (Chrome, Edge, Node.js) reports a zero-indexed character offset as 'position N'. Other engines report a line and column directly. This tool normalizes both formats into a single 1-indexed line/column pair by walking the input up to the reported offset and counting newlines, so the location shown stays consistent regardless of which browser rendered the page. Because parsing runs synchronously on the input string with no network request involved, validation of even multi-megabyte documents completes in milliseconds, and nothing about the document, including its content, size, or the fact that it was validated at all, gets transmitted anywhere.

JSON Validator Use Cases

  • Checking hand-written JSON config before deploying it, including package.json, tsconfig.json overrides, and infrastructure-as-code parameter files
  • Debugging why an API client fails to parse a response, by pasting the raw response body to get an exact error location instead of a generic client-side stack trace
  • Verifying JSON copied from a non-code source (email, PDF, chat, an LLM's output) where invisible formatting characters commonly break strict parsing
  • Teaching JSON syntax rules with immediate, precise feedback, useful for onboarding developers who are used to JavaScript object literals and haven't internalized where JSON's stricter grammar diverges
  • Sanity-checking machine-generated JSON, such as export output from a database tool or a log aggregator, before trusting it as an input to another system
  • Confirming that JSON pasted from a code review comment or documentation snippet is actually valid before copying it into a real config file

Common Mistakes

  • Confusing JSON with a JavaScript object literal: unquoted keys and single-quoted strings are valid JavaScript but invalid JSON.
  • Leaving a trailing comma after the last array item or object property, allowed in JS object literals and in JSON5/JSONC, but not in strict JSON.
  • Using comments (// or /* */), which aren't part of the JSON specification at all, even though tools like tsconfig.json (JSONC) tolerate them.
  • Writing an unescaped backslash inside a string, most often in a Windows file path like "C:\Users\dev", where the backslash must be doubled to \\.
  • Assuming duplicate keys will trigger a validation error. JSON.parse() silently keeps only the last value for a repeated key instead of rejecting the document.
  • Pasting two or more JSON documents concatenated together (common with NDJSON or copied log lines) instead of wrapping them in a single enclosing array.

Tips

  • If validation fails immediately after a large paste, check the very end of the document first, since truncated copies are a common cause.
  • Use the reported stats (depth, key count) as a quick sanity check that you pasted the document you meant to.
  • When an error points at a closing brace or bracket, the actual mistake is usually one or two tokens earlier, since the parser doesn't notice the problem until it reaches the character that breaks the pattern it expected.
  • If your JSON contains Windows file paths or regular-expression strings, search for lone backslashes first. That's the single most common cause of a 'bad escaped character' error.

References

Frequently Asked Questions