All tools

JSON validator

Check that a JSON document is valid.

JSON validator
InputValid JSONJSON

Press Command or Control plus Enter to run. Tab inserts indentation; press Escape, then Tab, to leave the editor.

Result
Your result will appear here.
Ready6 lines · 116 chars

About the JSON validator

A JSON validator checks whether a piece of text is valid JSON before you send it to an API, save it as a config file or parse it in code. A single missing comma or stray quote is enough to make a whole document unusable, and the error messages from applications are often vague.

This validator checks your JSON as you type and shows the line and column of the first problem it finds, so you know exactly where to look.

How to use the JSON validator

  1. Paste your JSON into the Input editor.
  2. Watch the label above the editor: it shows Valid JSON, or the line and column of the first error.
  3. Click Validate JSON or press Ctrl + Enter (Cmd + Enter on Mac) to get a full result and error message.
  4. Fix the reported problem and validate again until the JSON is valid.

Examples

Valid JSON

Input

{"enabled": true, "retries": 3, "hosts": ["a.example.com"]}

Output

JSON is valid. No syntax errors found.

Missing comma between two items

Input

{
  "name": "Ada"
  "age": 36
}

Output

Expected ',' or '}' after property value in JSON at position 20 (line 3 column 3)

The editor label shows the same location as Line 3, column 3, which is where the comma is missing.

Common errors and how to fix them

Unexpected end of JSON input

The input is empty or was cut off part way, often because a log line or a response body was truncated. Make sure every { and [ has its closing partner.

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

There is more than one JSON value, for example two objects one after another or a JSON Lines file. Wrap them in an array, [{...}, {...}], or validate one line at a time.

"undefined" is not valid JSON

You are validating the text undefined or [object Object], which usually means the value was printed before JSON.stringify was called. Log JSON.stringify(value) instead.

Good to know

  • Only the first error is reported, because parsing stops there. After you fix it, validate again to find any further errors.
  • The validator follows the JSON standard strictly. Comments, trailing commas, single quotes, unquoted keys, NaN and Infinity are all invalid.
  • Validation checks syntax, not structure. It cannot tell you whether a required field is missing; that needs a JSON Schema.

Frequently asked questions

What are the most common JSON errors?

Missing or trailing commas, single quotes instead of double quotes, unquoted property names, and comments copied in from JavaScript code. Unescaped line breaks inside strings are another frequent cause.

Is an empty object or a single value valid JSON?

Yes. {}, [], a string such as "hello", a number, true, false and null are all valid JSON documents on their own.

Does a valid result mean my API will accept the data?

It means the syntax is correct. The API can still reject it if fields are missing, misnamed or have the wrong type, so check its documentation or schema as well.