DevKitHub

JSON & Data

JSON Validator

Validate a JSON document and see precisely where parsing fails. Valid input also reports its size, total key count and maximum nesting depth.

4 lines
Result

This tool runs entirely in your browser. Your input is never uploaded, stored or logged.

How it works

Validation runs the same parser the formatter uses and reports where it stopped rather than what it produced. A document is valid or it is not; there is no partial credit, and the first error is the only one reported because parsing cannot meaningfully continue past it.

For valid input the report adds three measurements. Size is in UTF-8 bytes rather than characters, because that is what a network payload and a column limit actually count — a string of CJK text is three bytes per character. Key count is every key at every level. Depth counts container levels only: a bare value is depth 0, a flat object is 1, and an object containing an array is 3 only if that array contains another container.

Depth is worth checking before shipping a payload. Deeply nested documents are legal but hit real limits — some parsers impose a nesting cap, and recursive serialisers can exhaust the stack on input that looks unremarkable.

Common problems

Every example below is run against this tool in our test suite, so what it says here is what the tool actually does.

Input is empty

   
Why:
Whitespace alone is not a JSON document. An empty file is a common artefact of a failed write or an empty API response.
Fix:
JSON requires at least one value. Use null if you need an explicit empty document.

Unterminated string

{"a": "unclosed}
Why:
A string opened but never closed, usually a missing quote or a newline inside a string literal.
Fix:
Close the quote. Literal newlines inside strings must be escaped as \n.

Frequently asked questions

What counts as valid JSON?
JSON allows objects, arrays, strings in double quotes, numbers, true, false and null. It does not allow comments, trailing commas, single-quoted strings, unquoted keys, or values like NaN and Infinity.
What is nesting depth and why does it matter?
Depth is how many levels of objects or arrays are nested inside each other. Very deep structures can hit parser limits or cause stack overflows in some languages, so it is worth knowing before you ship a payload.

Last updated