How to Validate JSON Online

When an endpoint rejects a payload, first check the exact bytes it received. JSON validation can isolate a text-format error from an API contract mismatch. That distinction keeps you from rewriting fields when the real problem is a comma or an unexpected response wrapper.

Reproduce the parse failure

Copy a synthetic version of the raw request body with its punctuation intact. HTTP headers and status lines belong outside the body. Paste the body into the JSON Validator and run Validate JSON. The example fails because the array has a trailing comma.

A parser often reports the first token it cannot accept. Review the token immediately before the reported location too. Here the closing bracket is legal only after a value or on an empty array. Removing the comma makes the three-level structure clear: the root is an object, jobs is an array, and its first element is a string.

Invalid JSON
{"jobs":["sync",],"dryRun":true}
Result
{"jobs":["sync"],"dryRun":true}

A valid result can still reveal a bug

A result of Root type: string when your API expects an object often means the client serialized a JSON string again. If the body begins with a quote and contains escaped quotes, look for JSON.stringify applied both in your code and in an HTTP wrapper. Fix the serializer boundary to produce one layer.

If the root type is correct but the API complains, check required fields, enum values and nesting against its contract. For example, dryRun set to the string true parses successfully, yet a schema expecting a boolean will reject it. Add runtime schema validation where you ingest the data.

JavaScript
const body = JSON.stringify({ jobs: ["sync"], dryRun: true });
console.log(typeof JSON.parse(body));
console.log(typeof JSON.parse(JSON.stringify(body)));
Result
object
string

Make a regression fixture

Reduce the failing example to the smallest input that reproduces the issue. Retain any relevant Unicode, escape sequences and type differences while replacing private values. Save both a passing fixture and the former failure case. If the API returns JSON but the editor shows HTML, capture the status and content type before investigating syntax.

Frequently asked questions

Why does a JavaScript object literal fail?
Bare keys, single quotes and comments appear in JavaScript source. Standard JSON requires quoted keys and double-quoted strings.
Does the validator check duplicate keys?
It follows JavaScript parsing behavior, which can retain the last property with a repeated name. Use a stricter JSON linter if duplicate names must be rejected.

Try it with these tools

Related developer guides