Skip to content

Validate JSON

JSON Syntax Validation vs. Schema Validation

A document can parse as JSON and still violate the contract your application expects. The two checks answer different questions.

Last updated: October 24, 2026

Syntax validation asks, “Can this text be parsed as a JSON value?” Schema validation asks, “Does this parsed value meet the constraints described by this schema?” TheMyJSONPal JSON formatter parses and validates JSON syntax. TheJSON Schema Validator checks a JSON instance against a schema in your browser.

First: valid JSON syntax

JSON syntax requires double-quoted object keys and strings, valid comma and delimiter placement, and JSON values such as strings, numbers, booleans, objects, arrays, and null. A parser rejects malformed text before any schema rules can be evaluated.

{ "user": { "age": "thirty" } }

This example is syntactically valid JSON. The age value is a string; JSON syntax alone does not say whether the application should accept it.

Then: validate the data contract

A schema can require age to be a non-negative integer and user to be present. The valid JSON above fails that contract because "thirty" is a string, not an integer.

{
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "age": { "type": "integer", "minimum": 0 }
      },
      "required": ["age"]
    }
  },
  "required": ["user"]
}

Schema validation can check types, required properties, numeric ranges, formats, and other constraints described in the schema. A failure may point to a data path such as$.user.age; read the message and path to determine whether to change the input or the schema.

Choose the right check

  • Malformed text or a parse error: fix the JSON syntax, then parse it again.
  • Wrong type, missing field, or out-of-range value: validate against the JSON Schema that represents the intended contract.
  • Need a first draft of a schema: use the JSON Schema Generator on representative sample data, then review and complete the inferred rules.

A generated schema describes what appeared in the sample; it cannot infer every optional case, boundary, or business rule. The MyJSONPal validator supports declared schema drafts including 2020-12, 2019-09, Draft 7, Draft 6, and Draft 4. Local references can be resolved from the provided schema; remote $ref URLs are not fetched.

A practical validation sequence

  1. Parse or format the document to find JSON syntax errors first.
  2. Choose the schema version your application uses and provide the matching schema.
  3. Validate the instance and inspect each reported path and constraint.
  4. Correct the input or revise the schema only if it does not express the actual contract.
  5. Test with representative valid and invalid examples before relying on the rule set.

Open the JSON Schema Validator to run the second check. For common parse errors, see How to Fix Common JSON Errors.