Skip to main content

Free image, PDF & developer tools. No account needed.

HSQ ToolsHSQTools

JSON formatting vs JSON validation

Separate indentation, syntax checking and application schema requirements.

Reviewed by HSQ Tools ·

Formatting changes presentation

HSQ’s formatter parses JSON with JSON.parse and serializes it with JSON.stringify using two-space indentation. It can make nested objects easier to inspect. Invalid syntax must be corrected before formatting succeeds.

For example, {"items":[1,2],"active":true} gains line breaks and indentation. Its data structure is the same, but the original source text is not preserved byte for byte. Whitespace-sensitive signatures over the original bytes will change.

Syntax is only the first check

The validator checks whether the input parses as JSON. It does not check your API’s required fields, allowed values or JSON Schema. A syntactically valid {"age":"banana"} can still fail an application that requires a numeric age.

JSON requires double-quoted property names and strings. Trailing commas and comments are not accepted by these helpers. JavaScript object literal syntax is broader than JSON, so copying an object out of a script may need changes.

Know the parse-and-serialize limits

Large integers can lose precision in JavaScript numbers. Duplicate object keys are not reliably preserved: parsing generally leaves the later value. If these features matter, keep the original and use a parser designed for the requirement.

The formatter, validator and minifier run locally in the browser. This does not turn them into a schema validator or a secret-management tool. For a failing payload, first isolate the syntax error, then check the receiving API’s schema and business rules.

Work from the first parsing error

For an input such as {"items":[1,2,]}, remove the comma before the closing bracket and try again. The tool displays the browser parser’s error; wording and position details can vary by browser. Fix one syntax issue at a time before checking the application schema.

Format a copy of a known valid payload, then compare values with the original. Keep identifiers as strings when the receiving API defines them that way; do not change a numeric field to a string merely to silence an unrelated validation error.

Tools for this workflow