Text and data

JSON syntax vs schema validation: format and diagnose JSON

Valid JSON syntax only proves that a parser can read the document. It does not prove required fields exist, values have the right types or an API will accept the payload. Use PageUtil JSON Formatter for syntax, then validate the API contract separately.

A JSON parser returns formatted values or identifies the first syntax error.
Parsing checks JSON grammar; schema and business rules require separate validation.

Fix the first syntax error with a minimal sample

Paste the synthetic invalid object below into the formatter. JSON does not permit a trailing comma after the final member. Remove that comma and parse again. A parser often reports where it first became unable to continue; the true mistake can be just before that position.

Single-quoted property names and JavaScript comments also fail JSON grammar. Error text varies by browser, so use the line or position and nearby characters rather than searching only for one exact message.

Invalid JSON:
{"count":3,}

Corrected syntax:
{"count":3}

Compare syntax with the expected contract

Both payloads in the table parse correctly, but only one matches a contract requiring an integer count and an email string. A schema validator can report missing properties, types, bounds and disallowed extras. PageUtil does not run JSON Schema validation.

Even a schema-valid email string does not prove a mailbox exists, and a positive count may still exceed the current stock. Those are separate semantic or business checks. Name each validation layer precisely in error reports.

Three distinct checks
Input / ruleSyntax resultContract result
{"count":3,"email":"reader@example.com"}Valid JSONMatches the example field types
{"count":"3"}Valid JSONWrong count type; missing email
{"count":3,}Invalid JSONSchema evaluation cannot begin

State the schema and validate it separately

This small JSON Schema example uses the 2020-12 dialect. Save it with your API tests and run a validator supporting that dialect. It describes structure, not real mailbox verification or permission to place an order.

If the API still rejects a schema-valid payload, inspect its documented constraints, method, authentication, status and response body. A response beginning with < may be HTML rather than a JSON problem.

{
  "$schema":"https://json-schema.org/draft/2020-12/schema",
  "type":"object",
  "required":["count","email"],
  "properties":{
    "count":{"type":"integer","minimum":1},
    "email":{"type":"string"}
  },
  "additionalProperties":false
}

Inspect trees, compare diffs, and convert schemas

Within JSON Formatter, you can switch between the Formatter, Tree Viewer, JSON Diff, and Converters tabs without your data leaving the browser. The Tree tab provides collapsible inspection of deeply nested object hierarchies, while the Diff tab compares two payloads structurally regardless of key order.

You can also convert valid JSON directly into YAML, CSV, XML, or TypeScript interfaces. When large numeric identifiers or strict hash signatures are involved, keep an untouched source copy to preserve raw formatting.

References

Use the linked specifications and product documentation to check behavior in your own environment.

Continue troubleshooting

Related tools

Frequently asked questions

Does formatted JSON pass JSON Schema validation?

Not necessarily. Formatting confirms parsing, while schema validation checks a separate contract.

Can JSON contain trailing commas or comments?

No. Standard JSON grammar does not allow either feature.

Does PageUtil upload my pasted JSON?

No. JSON Formatter processes the pasted document in your browser.

Need help with a tool or found a bug?

Report an issue directly to engineering. No accounts required — all client data remains private on your device.

Report an Issue →