Skip to main content
CaseSwitch

Developer Guides

JSON Formatting vs Validation: What Each Check Proves

CaseSwitch editorial team · 2026-11-01 · 8 min

Formatting makes valid JSON readable; parsing checks syntax; JSON Schema validation checks whether the values fit an expected contract.

JSON formatting, syntax validation, schema validation, and application validation answer different questions. A payload can be beautifully indented and still contain the wrong customer ID. It can match a JSON Schema and still request a refund that exceeds a business limit. Knowing the boundary prevents a green formatter result from becoming false confidence.

Formatting changes presentation, not meaning

Pretty printing adds line breaks and indentation. Minifying removes insignificant whitespace. Both operations first parse the document and serialize the parsed value again. They are useful for reading logs, reviewing API examples, or shrinking a fixture, but they do not know what fields your application requires.

Use the JSON Formatter and Minifier for strict parsing, readable indentation, and one-line output.

Syntax validation asks whether it is JSON

  • Keys and strings use double quotes, not single quotes.
  • Objects and arrays have balanced braces and brackets.
  • Commas separate values but do not trail the last value.
  • The literals true, false, and null use lowercase spelling.
  • Comments and JavaScript expressions are not standard JSON.

A strict parser can answer those syntax questions. It may also normalize details during serialization: for example, 1.0 can become 1, and duplicate object keys usually collapse to the final value. That is why formatting should not be used as a cryptographic canonicalization scheme unless a specific standard defines the rules.

Schema validation asks whether the shape is allowed

JSON Schema can require properties, constrain strings, distinguish numbers from integers, limit arrays, and reject unexpected fields. A schema can say that status must be one of draft or published and that items must contain at least one entry. The formatter on CaseSwitch does not load or apply a schema, so a successful format does not make those claims.

Business validation belongs to the application

Some rules depend on databases, permissions, time, or other records. A valid date may still fall outside a booking window. A valid user ID may belong to another organization. Those checks require trusted server-side context and should run again at the boundary where the application accepts the request.

A practical validation sequence

  • Parse the payload and report a precise syntax error.
  • Validate it against the versioned schema used by the producer and consumer.
  • Apply authorization and business rules in trusted application code.
  • Log failures without exposing secrets or full production payloads.

For formatting examples and common syntax mistakes, continue with the guide to JSON formatting.

Related tools

Related guides