Skip to content
Popular tools

2026-08-18

How to validate JSON (syntax vs schema)

“Is this valid JSON?” and “Does this match our API?” are different questions. Mixing them up produces false confidence. A document can parse perfectly and still be missing the fields your service requires.

Syntax validation

Syntax validation asks whether a parser can read the text. In browsers that parser is JSON.parse. It enforces double-quoted strings, no trailing commas, and no comments. On Alphzen this is what the JSON Validator does. It also reports document stats such as root type and depth, which help you see what you actually pasted.

{
  "name": "Ada"
  "active": true
}

That snippet fails syntax validation: there is no comma after the first property. Line and column beat a raw “Unexpected token” message because you can jump to the problem.

Schema validation

Schema validation asks whether a parsed value matches a contract: required keys, types, enums, and nested shapes. JSON Schema, OpenAPI, and TypeScript types live in that layer. Alphzen does not pretend to do that work in the syntax tool.

What JSON.parse will not catch

  • Duplicate keys — engines keep the last value and do not throw
  • Wrong types, such as a string where you expected a number
  • Missing fields
  • Values that are valid JSON but meaningless to your application

Validate syntax first so you are not debugging a schema against broken text. Then check the contract with the tool that owns it — tests, generated clients, or a schema validator.