A formatter is most useful when it tells you exactly what the underlying parser accepts. Z Tools therefore tests representative inputs against native JavaScript JSON.parse and keeps the raw results with the source. The result is a small behavior matrix that is more actionable than a generic list of “JSON best practices.”

Seven parser cases in the bundled verification set

CaseResultWhy it matters
Valid objectParsedBaseline syntax
Trailing commaRejectedStrict JSON is not JavaScript object-literal syntax
Unicode textParsedJSON strings can carry Unicode
Leading BOMRejected in the tested native parserSome files need BOM removal before parsing
Invalid \x escapeRejectedJSON has a smaller escape grammar than JavaScript strings
9007199254740993ParsedSyntax can be valid even when JavaScript number precision is unsafe
100 nested arraysParsedNesting is valid until implementation/resource limits intervene

Syntax validity is not schema validity

JSON.parse answers “is this legal JSON?” It does not answer “does this object contain a valid user ID, currency, timestamp, or required field?” Applications should validate the parsed structure separately, using JSON Schema or explicit application checks. Z Tools intentionally calls itself a formatter/validator at the syntax level; it does not pretend to validate an unknown business schema.

Large integers are a classic false sense of safety

The test case containing 9007199254740993 parses successfully, but JavaScript’s ordinary Number cannot exactly represent every integer above Number.MAX_SAFE_INTEGER. If an API transmits database IDs or monetary minor units beyond that range, keep them as strings or use a parser/model designed for arbitrary precision.

Why error positions are “best effort”

Modern engines often include a numeric position or line/column in a SyntaxError, but the exact message is engine-specific. The Z Tools formatter extracts a position when the message exposes one and derives a line/column from the original text; it keeps the original parser message instead of inventing its own grammar.

Sorting keys changes presentation, not array order

The Sort keys control recursively sorts object property names but preserves array element order. That distinction is important: object key order is often irrelevant to a consumer, while array order frequently encodes business meaning. Sorting an array “for readability” would silently change data.

Local file loading and privacy boundary

The JSON file picker reads .json or text files locally with FileReader and caps the client-side file at 5 MiB. The formatter does not submit the document to a JSON-processing endpoint. As documented in the site FAQ, avoid putting secrets into a shareable/reloaded URL if a tool state is synchronized into the query string, because access analytics record the requested path.

Reference

For the grammar itself, use RFC 8259. For application validation, treat RFC-valid JSON as the beginning of validation, not the end.