JSON Validator

Paste your JSON and instantly see whether it's valid. Errors include line numbers when possible.

Paste JSON to validate
0
Characters
0
Keys
0
Max depth
-
Root type

What validation checks

A JSON validator confirms that a document conforms to the JSON grammar. It checks syntax only - that brackets balance, strings are properly quoted, and values are of legal types. It cannot tell you whether the data is correct, complete or sensible.

That distinction matters. {"age": "forty"} is perfectly valid JSON, and also probably a bug. Validating structure is the job of JSON Schema, which is a separate layer.

Key takeaways

  • Validation checks grammar, not meaning.
  • The reported error position is where parsing failed, not always where the mistake is.
  • Unbalanced brackets are typically reported far from the actual problem.
  • JSON Schema validates structure and types; syntax validation does not.
  • A byte order mark at the start of a file is a classic invisible cause of failure.

Error messages and what they mean

ErrorUsual cause
Unexpected token } in JSONA trailing comma before the closing brace
Unexpected end of JSON inputA bracket or brace was never closed
Unexpected token ' in JSONSingle quotes used instead of double
Expected property name or }An unquoted key, or a stray comma
Unexpected non-whitespace character after JSONTwo JSON documents concatenated, or trailing content
Unexpected token < in JSONThe response was HTML - often an error page, not JSON
Bad control character in string literalA literal newline or tab inside a string
"Unexpected token < in JSON at position 0" is the most-searched JSON error for a reason. It almost never indicates a JSON problem. It means your code tried to parse an HTML page as JSON - usually a 404 page, a login redirect, or a server error page returned where an API response was expected. Check the actual HTTP status and response body before looking at your parsing code.

Why the error position can mislead

A parser reports where it could no longer continue, which is not necessarily where the mistake is. If you forget a closing brace on line 5, the parser happily reads on and only fails at the end of the file - reporting line 500 for a problem on line 5.

  • For "unexpected end of input", look for an unclosed bracket, brace or quote somewhere before the reported point.
  • For a reported line that looks fine, check the lines immediately above it.
  • Use a formatter - pretty-printing makes unbalanced structure visually obvious.
  • Bisect large documents. Cut the file in half and validate each part to narrow the search.

Invisible causes of failure

ProblemSymptomFix
Byte order mark (U+FEFF)Fails at position 0 despite looking validSave the file as UTF-8 without BOM
Smart quotes from a word processorUnexpected token errorReplace with straight double quotes
Non-breaking spaceUnexpected token errorReplace with a normal space
Literal tab inside a stringBad control characterEscape it as \t
Windows line endings inside stringsBad control characterEscape as \r\n
Truncated responseUnexpected end of inputCheck for a size or timeout limit upstream
The BOM problem is genuinely maddening. A byte order mark is an invisible three-byte prefix that some Windows editors add when saving UTF-8. The file looks identical in every viewer, but the parser sees an unexpected character at position 0. If your JSON looks perfect and still fails immediately, this is the first thing to check.

Syntax validation versus schema validation

Syntax validationJSON Schema validation
ChecksGrammar and structureTypes, required fields, formats, ranges
Catches a missing bracketYesYes, indirectly
Catches a missing required fieldNoYes
Catches a string where a number belongsNoYes
Catches an invalid email formatNoYes
Needs a schema definitionNoYes

This tool does syntax validation. If you need to guarantee that an API payload has the right shape, JSON Schema is the appropriate tool and is supported by libraries in every major language.

Avoiding invalid JSON in the first place

  1. Never build JSON by string concatenation. Use your language's serializer, which escapes correctly every time.
  2. Validate at API boundaries, not deep inside business logic where the error context is lost.
  3. Wrap parsing in error handling and log the raw response when it fails - that is how you discover you were sent HTML.
  4. Check the content type and status code before parsing.
  5. Add a linter to CI for JSON files kept in version control.
  6. Use an editor with JSON syntax highlighting, which catches most mistakes as you type.
Everything runs in your browser. Your data is processed entirely on your own device - nothing is uploaded, logged or stored. That matters when the payload you are debugging contains customer records, API responses or anything else you should not be pasting into a remote service.

Frequently Asked Questions

What does a JSON validator check?

It checks that the document follows the JSON grammar - balanced brackets, properly quoted strings, legal value types and correct comma placement. It validates syntax only, not whether the data itself makes sense.

What does "Unexpected token < in JSON at position 0" mean?

That your code tried to parse HTML as JSON. The response was almost certainly a 404 page, a login redirect or a server error page returned where an API response was expected. Check the HTTP status and the raw response body rather than your parsing code.

Why does the error point to a line that looks fine?

Because a parser reports where it could no longer continue, not where the mistake was made. A brace left unclosed on line 5 is only detected at the end of the file. Look above the reported position for unbalanced brackets or quotes.

My JSON looks perfect but still fails at position 0. Why?

Almost certainly a byte order mark - an invisible three-byte prefix some Windows editors add when saving UTF-8. The file looks identical everywhere but the parser sees an unexpected character. Re-save as UTF-8 without BOM.

What is the difference between JSON validation and JSON Schema?

Syntax validation checks that the document parses. JSON Schema checks that it has the right shape - required fields present, values of the correct type, strings matching expected formats. A document can be perfectly valid JSON and still be completely wrong for your application.

Why does my JSON fail with "bad control character"?

Because a literal newline, tab or carriage return appears inside a string. Control characters below U+0020 must be escaped - use \n for a newline and \t for a tab rather than the raw character.

Can I validate very large JSON files here?

Yes, subject to your device's memory. Validation runs in your browser, so very large files of many megabytes may be slow but will generally work. For files that large, a command-line tool is usually more comfortable.

Is my JSON uploaded anywhere?

No. Validation runs entirely in your browser and nothing is transmitted or stored, which matters when the payload contains real customer or production data.

Related Calculators