Add to Chrome Add to Edge

JSON Validator

Paste JSON and check in one click whether it is valid, with the reason when it is not.


JSON Validator

JSON Validator tells you whether a piece of JSON is valid. Paste it in, click Validate JSON, and you get either "JSON is Valid" or "Invalid JSON Provided" followed by the reason, such as Syntax error or Malformed UTF-8 characters. The check is run by SEOpeck's server with PHP's standard JSON parser, the same parser many websites and APIs use to read JSON.

How to use the JSON Validator

  1. Paste your JSON into the box: an API response, a config file, a package.json or a block of test data.
  2. Click Validate JSON.
  3. Read the message under the button. If it says invalid, fix the problem and validate again.

What the error messages mean

  • Syntax error: the text breaks a JSON rule. It covers most mistakes: a trailing comma, single quotes, an unquoted key, a comment, a missing bracket or a stray character before or after the data.
  • Control character error, possibly incorrectly encoded: a string contains a raw tab or line break. Inside JSON strings these must be written as \t and \n.
  • Malformed UTF-8 characters: the text contains bytes that are not valid UTF-8, usually from a file saved in another encoding such as Windows-1252.
  • Maximum stack depth exceeded: the data is nested 512 or more levels deep.

A worked example

This looks fine at a glance but is invalid:

{
  'name': "SEOpeck",
  "tools": ["dns-lookup", "ping",],
}

The validator answers Invalid JSON Provided: Syntax error. There are three problems: the key 'name' uses single quotes, and there is a trailing comma after "ping" and another after the closing bracket. The corrected version is valid:

{
  "name": "SEOpeck",
  "tools": ["dns-lookup", "ping"]
}

Common mistakes and how to fix them

  • Trailing commas: JavaScript allows them, JSON does not. Remove the comma before every } and ].
  • Single quotes: keys and strings need double quotes.
  • Comments: // and /* */ are not part of JSON. Delete them, or use a format that allows them, such as YAML (convert it with YAML to JSON).
  • JavaScript values: undefined, NaN and Infinity are not valid JSON. Use null or a number.
  • A hidden byte order mark: some Windows editors save files with an invisible BOM at the start, which this parser rejects as a syntax error. Save the file as "UTF-8" without BOM.

When it comes in handy

  • Checking an API request body before you send it, or a response that your code refuses to parse.
  • Testing a config file after a hand edit, before you deploy it.
  • Making sure data exported from another system is well-formed before you import it or convert it with JSON to CSV.

Limits

  • The result says what is wrong, but not where. To get the line and column of the error and a plain-English hint, paste the same JSON into the JSON Beautifier, which also formats valid JSON and runs entirely in your browser.
  • It checks syntax only, not whether the fields match a JSON Schema or what your API expects.

Not sure JSON is the right format for your data? Our guide to JSON vs XML vs CSV compares them.

Frequently asked questions

Why does my JSON fail here but work in JavaScript?
JavaScript object syntax is looser than JSON. Unquoted keys, single quotes, trailing commas and comments all work in a .js file but are errors in JSON.
Does it tell me the line number of the error?
No. It reports the type of error only. The JSON Beautifier shows the line and column where parsing stopped.
Are duplicate keys invalid?
No. The JSON standard (RFC 8259) says keys should be unique but does not forbid repeats, so this validator accepts them. Most parsers, including this one, keep only the last value, so duplicates usually point to a bug in whatever produced the data.
Is JSON-LD schema markup checked here?
Only its JSON syntax. To test structured data on a live page, use the JSON-LD Validator.
Is my JSON stored?
No. It is sent to our server to be parsed and the result is shown straight away; the tool does not save it. Still, remove API keys, tokens and personal data before pasting JSON into any online tool.

Related guides

Related Tools

Choose which cookies SEOpeck may use. You can change this at any time from "Cookie settings" at the bottom of every page.

Your tools

    Saved in this browser only. Nothing is sent to us.

    Popular tools