JSON is easy for software to exchange and difficult for people to inspect when it arrives on one long line. Formatting adds indentation and line breaks so nested objects and arrays become visible. Validation checks whether the text follows JSON syntax before an application tries to use it.
Formatting aims to make the same information easier to read, but the ToolsOnDuty helper parses JSON into JavaScript values and serializes those values again. It is not a byte-preserving whitespace editor. Ordinary supported values retain their meaning, while duplicate keys, very large numbers and lexical forms need extra care.
What valid JSON requires
A JSON document contains an object, array, string, number, boolean, or null value. Object keys and string values use double quotes. Items are separated by commas, and nested structures must close with the matching brace or bracket.
- Use double quotes around every object key.
- Do not leave a trailing comma after the final item.
- Escape double quotes and backslashes inside strings.
- Use true, false, and null in lowercase without quotes.
Common JSON syntax errors
Single quotes are common in JavaScript but invalid in strict JSON. Comments are also not part of the JSON standard. Missing commas, extra commas, unescaped line breaks, and mismatched brackets account for many parsing failures.
When a parser reports a position, inspect the character immediately before it as well. The parser often notices a problem only when it reaches the next token, so the actual mistake may be a missing comma or quote on the previous line.
{
"project": "Example project",
"ready": true,
"items": ["draft", "review"]
}
Format without changing the data
Paste your source into JSON input or use Open file for a local text file. Click Format JSON to generate two-space indentation, or Minify for compact output. Input is not automatically overwritten. This workspace does not offer a four-space indentation selector.
Processed output can be copied or saved with Download .json as formatted-data.json. Clear removes the working text. Editing the input clears stale output, so generate it again before copying. Review the whole result and keep an untouched source outside the tab.
No explicit sort-keys option is provided. JavaScript object serialization can still reorder integer-like keys, and parsing can remove duplicate members. Keep array order and data types under review rather than treating the action as an exact source-preservation guarantee.
Try a nested example and distinguish strings from numbers
Use the following synthetic JSON. Format JSON should show an object with two top-level keys, project and items. The items value is an array of two objects, not a count of two top-level keys. Review the indentation to see which properties belong to each object.
{"project":"Example project","items":[{"id":"0012","quantity":2},{"id":"0013","quantity":0}]}The identifiers are quoted strings, so their leading zeros remain. Quantity is numeric; changing 2 to "2" changes its type even if it looks similar on screen. Minify removes presentation whitespace but does not turn string identifiers into numeric values. Confirm types with the consuming application, not appearance alone.
Know when parse-and-serialize can lose information
Duplicate object members are a practical danger. Formatting {"status":"draft","status":"published"} produces only the last status value, published. The parser can accept that text while discarding the earlier member. Valid-looking output is not proof that a document had no duplicates.
JavaScript numbers cannot exactly represent every large integer. In this helper, {"id":9007199254740993} serializes as {"id":9007199254740992}. If an API specifies long identifiers as strings, keep them quoted from the start. A formatter cannot recover digits already lost when a system converted them to an imprecise number.
Duplicate members:
{"status":"draft","status":"published"}
Minified output: {"status":"published"}
Unsafe integer input:
{"id":9007199254740993}
Minified output: {"id":9007199254740992}Other lexical differences can include 1.0 becoming 1 or an escape becoming its equivalent character. For signed payloads, checksums or systems requiring exact bytes, retain the original serialization and use an appropriate source-preserving workflow. Do not roundtrip through a general formatter before signature verification.
Syntax validity is not schema or business validity
The JSON status panel checks parsing. An object with an unexpected field name, a negative quantity or a missing required property can still be valid JSON. This tool does not know the consuming application's schema, authorization policy or acceptable ranges.
Use the destination's validator or tests to check required keys and allowed values. When an error appears, make one small correction, format again and compare the result with your retained source. For sensitive examples, reduce the document to synthetic data instead of distributing a complete production response.
Handle sensitive JSON carefully
API responses and configuration files may include access tokens, customer records, internal URLs, or credentials. Remove secrets before sharing examples. For private data, prefer a formatter that runs locally in your browser instead of sending the document to a remote service.
After the formatter validates the structure, compare the result with the source before copying it or converting suitable tabular data to CSV. The operation runs on the page and does not require an account.
Try the related tools
Apply the steps from this guide directly in your browser.
Frequently asked questions
Does formatting JSON change its data?
The current tool parses and reserializes JSON rather than editing whitespace alone. Ordinary supported values retain meaning, but duplicate keys, unsafe integers and exact-byte requirements need care. Compare the result with the original.
Why are single quotes invalid in JSON?
The JSON specification requires double quotes for object keys and strings. Single quotes may work in JavaScript source code, but they are not valid JSON syntax.
Can JSON contain comments?
Standard JSON does not support comments. Put explanatory information in a normal data field or use a different configuration format that explicitly supports comments.
