JSON Formatter
Pretty-print JSON with your choice of indentation, sorted keys and clear line-and-column error messages.
This guide is not yet available in your language and is shown in English.
Tool guide
What this tool does
JSON Formatter turns minified or messy JSON into neatly indented, readable text. It keeps every number and string exactly as written, points to the precise line and column of any syntax error, and can accept JSONC-style comments and trailing commas while outputting strict JSON.
API responses, log lines and exported configuration files usually arrive as a single dense line of JSON. That is efficient for machines but almost impossible for a person to read, review or debug. Reformatting by hand risks breaking the structure, and many quick formatters silently change your data: they round long integers such as 12345678901234567890 to 12345678901234567000 because they pass everything through JavaScript numbers.
This formatter uses its own lossless parser, so number and string literals are copied character for character and only whitespace changes. It follows the JSON grammar in RFC 8259 and, when something is wrong, explains the problem in plain words with the line, the column and a short excerpt marked with a caret. Everything runs locally in your browser, so internal API payloads and customer data never leave your device, and files of several megabytes are processed with a short delay rather than freezing the page.
How to use JSON Formatter
- Paste JSON into the JSON input box, drop a .json file onto it, or click Sample to load an example.
- Choose the Indentation in Options: 2 spaces, 4 spaces, 3 spaces or a tab.
- Turn on “Allow comments and trailing commas” if your input is JSONC or JSON5-style, such as a tsconfig.json or VS Code settings file.
- Optionally enable “Sort keys alphabetically”, “Keep short arrays on one line” or “Escape non-ASCII characters”.
- Read the Formatted JSON output, or the error message with its line and column if the input is invalid.
- Copy or download the result, or use “Convert several files” to format a batch of files and download them as a ZIP.
Tips for better results
- Two-space indentation is the most common choice in JavaScript projects; four spaces is typical for Python and many Java style guides.
- Sorting keys gives a stable order, which makes Git diffs of configuration files much easier to review.
- If a warning says an integer exceeds 2^53, any JavaScript consumer will round it. Ask the API owner to send such IDs as strings.
- Duplicate keys are reported as a warning because most parsers silently keep only the last value, which hides bugs.
Common use cases
- Reading a minified REST or GraphQL response while debugging an integration.
- Tidying package.json, composer.json or app settings before committing them.
- Making webhook payloads readable before pasting them into a bug report.
- Normalising JSON fixtures so test data has a consistent style across a team.
Common mistakes to avoid
- Expecting comments to survive: standard JSON has no comments, so relaxed mode removes them from the strict output.
- Pasting a JavaScript object literal with undefined, NaN or functions; these are not JSON values and are reported as errors.
- Formatting JSON with escaped quotes copied from a log (for example {\"a\":1}). Unescape the string first, or the formatter sees a single invalid value.
Frequently asked questions
Does formatting change my data?
No. Only whitespace is added or removed. Keys, string escapes and numbers are written exactly as they appear in the input, including very large integers and values such as 1.50 that other tools would shorten to 1.5.
How large a file can I format?
Files of several megabytes work well on a modern laptop. Input over about 200 KB is processed after a short pause in typing and a progress indicator is shown, so the page stays usable.
What does relaxed mode accept?
Line and block comments, trailing commas, single-quoted strings and unquoted property names, which covers JSONC files and most JSON5 documents. The output is always strict JSON that any parser accepts.
Why is my JSON reported as invalid when JavaScript accepts it?
JavaScript object literals are more permissive than JSON. JSON requires double-quoted keys and strings, forbids trailing commas and comments, and has no undefined, NaN or Infinity.
Related articles
- Why Toolew runs your tools in the browserHow Toolew processes files on your own device with JavaScript and WebAssembly, what that means for privacy and speed, and which tools use the network.
- JSON formatting and validation: a practical guide for developersWhy JSON breaks, how to read parser errors, when to pretty-print or minify, and a repeatable workflow for cleaning API responses and config files.
Feedback & suggestions
Help us improve JSON Formatter. We read every message.