JSON formatter
Format JSON online with 2-space, 4-space or tab indentation. Checks the syntax as you paste and describes any error. Runs locally in your browser, no sign-up.
About JSON formatter
The JSON formatter turns compact or messy JSON into readable, consistently indented text. Paste an API response, a config file or a log entry, choose 2 spaces, 4 spaces or tabs, and the formatted result appears as you type. The input is parsed first, so you also know whether the JSON is valid before you copy it anywhere.
It uses your browser’s built-in JSON parser, which follows the same strict rules as JSON.parse in JavaScript, so anything that passes here will parse in Node.js, browsers and most other languages. Everything runs locally, which makes it suitable for responses that contain tokens, customer records or internal URLs.
How to use JSON formatter
- Paste JSON into the input box, open a .json file, or drop a file onto the box.
- Choose 2 spaces, 4 spaces or Tabs for the indentation.
- Read the status bar: “Valid JSON” with a character count, or an error message describing the problem.
- Copy the formatted result or download it as a .json file.
Features
- Indents with 2 spaces, 4 spaces or tabs, and switches to a single minified line with the Minify option.
- Parses with the browser’s strict JSON parser: no comments, trailing commas, single quotes or unquoted keys.
- Reports the line and column of a syntax error when the browser provides a position for it.
- Keeps key order and writes escape sequences such as \u00e9 as the characters they represent.
- Accepts pasted text or text files up to 2 MB, processed in a background worker so the page stays responsive.
Common uses
- Reading a minified API response copied from the browser’s network tab or a curl command.
- Tidying a package.json or composer.json file before committing it.
- Making a webhook payload readable before writing code to parse it.
- Preparing JSON samples for documentation, bug reports or code reviews.
Tips
- Integers larger than 9,007,199,254,740,991 can lose precision when parsed, so very long numeric IDs may change in the output. Store such IDs as strings.
- If an object repeats a key, only the last value is kept in the formatted result.
Frequently asked questions
Why does my JSON fail with an “Unexpected token” error?
Strict JSON does not allow comments, a trailing comma after the last item, single-quoted strings or unquoted keys. JavaScript object literals and JSON5 files often contain these. Remove them and use double quotes for every key and string, and the input will parse.
Should I indent JSON with 2 spaces, 4 spaces or tabs?
All three produce equivalent JSON, because whitespace outside strings means nothing to a parser. Two spaces is the norm in JavaScript projects and package.json files, four spaces matches common Python output, and tabs suit teams that let each editor choose the width. Follow your project’s existing style.
Does formatting change my data?
Values are not changed, with two exceptions that come from JSON parsing itself: if an object repeats a key, only the last value is kept, and integers beyond 2^53 may be rounded. Escape sequences such as \u00e9 are written out as the character, which is the same string.
What is the difference between the JSON formatter and the JSON validator?
Both use the same strict parser. The formatter page is aimed at producing readable output in your chosen indentation, while the validator page focuses on checking input and locating errors. Either one reports syntax errors and either one can show formatted output.
Can it format JSON Lines or several JSON objects at once?
No. The input must be a single JSON value, such as one object or one array. For JSON Lines, where each line is a separate object, wrap the lines in square brackets and add commas between them to make one array first.
Is my input uploaded?
Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.
Your privacy comes first
Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.