A formatter asks whether text can be parsed and how it should be indented. A validator may ask whether syntax is legal or whether the parsed value satisfies a schema.
The jobs overlap: formatters parse and therefore detect syntax errors. But pretty output does not prove required fields, data types, formats, ranges, or business rules.
Five different contracts
Formatting changes presentation; syntax validation checks grammar; schema validation checks structure and constraints; linting adds quality rules; repair transforms invalid input.
One UI can expose several modes, but “valid JSON” must not silently mean “valid for our API.”
| Tool | Question | Changes input |
|---|---|---|
| Formatter | How should valid data look? | Whitespace |
| Syntax validator | Is grammar legal? | No |
| Schema validator | Does data satisfy a contract? | No |
| Linter | Does it meet quality rules? | Usually no |
| Repair | Can invalid input be transformed? | Yes |
Syntax-valid is not contract-valid
{"age":"eighteen"} is valid JSON. It fails a schema requiring a non-negative integer. An empty object is valid JSON but may fail an API requiring id and email.
Schema validation begins after parsing and evaluates keywords such as type, required, properties, items, enum, pattern, minimum, and additionalProperties.
Formatter syntax feedback has limits
A JSON.parse formatter reports missing commas, bad strings, and trailing characters because it cannot indent invalid input.
A JSON5-capable formatter may accept comments and trailing commas. It must label the grammar, or users may assume the source is acceptable to a strict API.
Repair is transformation
Repair may remove comments, quote keys, convert single quotes, close structures, or remove trailing commas. Ambiguous data can change meaning.
A trustworthy repair tool preserves the original, shows output, and asks for review; repaired success is not proof the original passed validation.
Recommended workflow
Parse first. If parsing fails, repair explicitly and review. Format the parsed value, validate against schema, then apply business rules such as cross-field totals.
Keep syntax, schema, and domain errors separate because ownership and fixes differ.
- Parse original text.
- Review repaired output.
- Format the result.
- Validate with JSON Schema.
- Apply business rules last.
Which ToolGarden tool to use
Use Formatter for indentation, minification, tree inspection, and syntax feedback; Schema Validator for a defined contract; Repair for comments, trailing commas, single quotes, or malformed text.
All run in browser JavaScript, so payloads do not need a validation backend.
Key takeaways
Formatting improves representation, syntax validation proves grammar, and schema validation checks a contract. Separate stages prevent “it formatted successfully” from becoming a false guarantee.