ToolNest · Published · Updated
How to format and validate JSON
Pretty-printing JSON is mundane until the payload contains a token. Running JSON.parse locally is the boring, correct default.
Before you begin
JSON Formatter parses and formats JSON. A valid JSON document can still fail your application's schema or business rules.
Use JSON FormatterWorked example: Inspect a small API response
- Input
- {"order":42,"paid":true}
- Expected output
- Indented JSON containing order: 42 and paid: true.
Beautify changes whitespace to make the structure easier to inspect. It does not validate your business schema or prove that an API response is trustworthy. JSON requires quoted property names and does not allow a trailing comma after the final property.

Check the result
Compare types before copying: true is a boolean, while "true" is a string. Very large integer identifiers may lose precision through JavaScript parsing; represent such identifiers as strings when your schema permits.
If it does not work
An input such as {broken is invalid. Check matching braces, commas and double quotes. JavaScript object literals and commented configuration files are not necessarily valid JSON.
Scope and limitations
Use double-quoted keys and remove comments or trailing commas. Keep long numeric identifiers as strings to avoid JavaScript precision loss.
Use Base64 Encoder if the JSON arrives inside a Base64 text payload, then format the decoded JSON.
Beautify vs minify
Beautify adds indentation so you can read structure. Minify removes whitespace for a compact paste. Both fail if the input is not valid JSON — trailing commas and comments are not valid JSON.
Read the error
The message comes from the engine’s JSON parser. It usually points near the first problem, not every problem.
Inspect a small response without changing its meaning
Paste {"order":42,"paid":true} and select Beautify. Check that 42 is still a number and true is still a boolean. Formatting introduces whitespace; it does not confirm that the order exists or that a payment actually happened. Treat these as synthetic fields for learning, not a record from a live customer.
Resolve syntax before checking your schema
Try the malformed input {broken. The parser should report an error. JSON keys need double quotes, and trailing commas and comments are not standard JSON. Once syntax works, use a schema-aware validator if you need to require fields or constrain their values. This formatter is not that validator.
Protect exact identifiers
JavaScript numbers do not preserve arbitrarily large integers. If an API uses long account IDs, follow its schema and preserve them as strings where appropriate. Do not paste production credentials or personally identifying responses merely to make them easier to read; replace sensitive values with a harmless fixture first.
Questions
Will this sort keys?
No. It preserves key order as parsed.
Related tools
Continue reading
Technical references
- MDN: JSON parsing and number precision
JSON syntax, parsing errors and why long numeric identifiers can lose precision.
- RFC 4648: Base64 encoding
The encoding specification. Encoding represents data; it does not provide confidentiality.
- MDN: cryptographic text digests
How browser digest algorithms work and their security limitations.
These instructions describe ToolNest's browser tools and their limitations. Read how examples are maintained or report a correction.