Free tools • Fresh ideas
JSON Formatter
Indent JSON with two spaces to make nested records easier to review.
How to use the JSON Formatter
Use this on responses or configuration files you want to review in a code editor. JSON strings with escaped quotes, tabs and newlines stay valid. The browser parses and serialises the document, so duplicate keys collapse to the last value and very large integers can lose precision. Represent IDs as strings before formatting.
Example input
{"film":"Arrival","tags":["drama","science fiction"]}
Read the shape of a JSON response
Formatted JSON makes it easier to trace the relationship between a response and the code that consumes it. Imagine a library catalogue response with a top-level object, a results array, and a separate count. With indentation, you can see which properties belong to the response as a whole and which belong to a single book. This matters when your code reads a property from the wrong level. A missing property often produces an undefined value even though the name appears somewhere in the response.
Start with the smallest representative input. Paste a single response and select Load example if you need a working baseline. Compare an object, which uses named keys, with an array, which contains a sequence of values. Open the output in an editor with matching-bracket support when the document has many nested levels. When you find the field you need, trace back to the enclosing object before writing the code that accesses it.
Use formatting to investigate a failed request
If formatting fails, first verify that the input really is JSON. An HTTP error can return an HTML page beginning with a less-than sign, instead of the response you expected. A successful response may also be empty. In the browser’s network inspector, look at the HTTP status, response headers, and response body together. A change to indentation cannot turn HTML, an empty body, or a partial response into a complete JSON document.
An error near a brace or bracket often comes from the preceding field. Check for a trailing comma, an unclosed string, or a missing colon. JSON keys and string values use double quotes. JavaScript object literals allow several conveniences that JSON does not, including unquoted names. If your source is a JavaScript object in a programme, serialize the actual value with a JSON serializer. Avoid converting large object literals by running replacement expressions over the whole file.
Know which details a parser can change
This formatter parses the input and serializes the resulting value. It preserves valid string content, but it does not preserve the exact source bytes. Escape sequences can be represented differently after serialization. Object keys that look like array indexes may appear in numeric order. Duplicate keys collapse because the underlying representation retains the last assigned value for each name. If a duplicate key was the fault you were trying to investigate, preserve the original input for a separate diagnostic.
Numbers use JavaScript’s numeric precision. A long numeric account identifier can change even when the output still parses. When designing an API, agree on a string representation for identifiers whose exact digits matter. If you have already received a document containing such numbers, save the raw response and use tooling that can preserve those numeric tokens without converting them to ordinary JavaScript numbers.
Digital signatures and hashes may depend on the original bytes. Keep the original document for signature checks and use a formatted copy for inspection. Different indent settings and line endings can produce different hashes even when the two parsed values are equivalent. Some systems define a specific canonical serialization. This formatter does not implement those protocols.
Choose between formatting, validation and compact output
Use the formatter for review and debugging. Use the validator when you only need to know whether the document parses. Neither operation checks your API schema, required fields, or business rules. A valid record can still contain a misspelt key, the wrong date format, or a number where an application expects a string. Use a schema validator or your application’s own tests for those checks.
For smaller transferable text, try the JSON Minifier after you have checked correctness. Test a small response first and avoid feeding several megabytes into an interactive browser utility. If the file is generated by a build, configure the producer to write the desired form. That removes a manual step and makes the result repeatable.
Related tools
Related guides
- HTML for Beginners: Build Your First Web Page
- Build Your First Website With HTML and CSS
- HTML Tags and Attributes: A Practical Beginner’s Guide