What is JSON Formatter?
This JSON formatter turns compact or minified JSON into clean, indented, human-readable JSON. APIs, logs and databases usually send JSON on a single line to save bytes, which is impossible to read; paste it here and it is pretty-printed instantly, one property per line, with line numbers and syntax colors.
Formatting only changes whitespace. Every number keeps its exact digits and every string keeps its escapes, so a 64-bit ID such as 9007199254740993 isn't rounded the way it is by tools built on JSON.parse. If the JSON is invalid, the formatter gives the line and column, explains the problem in plain words and can fix common mistakes such as trailing commas, single quotes and comments for you. Switch to the tree view to expand, collapse, search and copy any part of the document.
How to use JSON Formatter
- Paste JSON into the input panel, open a file, drop one on the page, or load it from a URL.
- The formatted JSON appears in the output panel straight away, with line numbers and syntax colors.
- Choose 2, 3 or 4 spaces or tabs, and turn on Sort keys to order every object's keys from A to Z.
- If there's an error, click Go to error to jump to it, or Fix automatically to repair it.
- Copy or download the result, convert it to YAML, XML or CSV, or switch to Tree to explore it; press Ctrl+F to search.
Key features
- Pretty print with 2, 3 or 4 spaces or tabs, or minify to one line
- Sort keys A to Z at every level
- Exact output: numbers keep every digit and strings keep their escapes
- Syntax errors with the line, column and a plain-English explanation
- Go to error, and Fix automatically for trailing commas, quotes, comments and more
- Code view with line numbers, syntax colors and search
- Tree view with expand, collapse, search, copy-node and copy-path
- Open files up to 50 MB, drag and drop them, or load JSON from a URL
- Warnings for duplicate keys and for numbers JavaScript would round
- Copy, download, or convert the result to YAML, XML or CSV
Common use cases
- Reading minified REST and GraphQL API responses
- Formatting JSON log lines from Docker, Kubernetes or serverless functions
- Cleaning up package.json, tsconfig.json and other config files before committing
- Inspecting JSON exported from MongoDB, PostgreSQL JSONB or DynamoDB
- Preparing readable JSON samples for documentation and bug reports
Technical details & standards
The formatter uses its own strict RFC 8259 parser rather than JSON.parse, and re-prints the document by copying every value exactly as written, so only whitespace changes. Numbers keep all their digits (including integers above 2^53 − 1, which JSON.parse rounds, and forms such as 1.50 or 1e5), strings keep their escape sequences, and keys stay in their original order unless you sort them. Sorting applies at every level and uses Unicode code point order, like jq -S and Python's sort_keys. The parser also flags duplicate keys, which most JSON parsers silently reduce to the last value.
Errors are reported with the line and column and a plain-words description that is the same in every browser. Files and URL responses up to 50 MB can be opened; the code view and the tree only render the rows on screen, so large documents scroll smoothly. Pasted JSON and local files are processed in your browser. Load URL sends a request directly to the destination you enter.
Pretty print a compact API response
Try this input in the workspace above.
- Paste {"status":"ok","items":[{"id":42,"qty":2}]} and select two-space indentation.
Result: Each field gets its own line, and the item’s fields are indented inside the array. Remove the comma after the last property if the source fails with a trailing-comma error.
Format JSON without losing large integers
Database IDs in API responses can exceed JavaScript’s safe integer range. This formatter preserves number tokens as written, so making a response readable does not change its IDs.
Example input
{"id":9007199254740993,"status":"ok"}- Paste the compact response into the input and select 2-space indentation.
- Compare the ID in the output with the original: it must still end in 993, rather than the rounded 992.
- Copy or download the formatted result. A downstream JSON.parse can still round this number; use a lossless parser or have the API return IDs as strings.
Expected result
{
"id": 9007199254740993,
"status": "ok"
}Continue with a related task:
Frequently asked questions
How do I pretty print JSON?
Paste the JSON into the input panel and the formatted version appears immediately. In code, JavaScript's JSON.stringify(value, null, 2), Python's json.dumps(value, indent=2) and the command line's jq . all pretty print JSON.
Why does the formatter show an error instead of formatted JSON?
The input is not valid JSON. The message under the panes gives the line and column and says what's wrong; the most common causes are trailing commas, single quotes, unquoted keys and comments. Click Go to error to jump to the problem, or Fix automatically to repair these mistakes in one step, then check the result.
Should I use 2 or 4 spaces to indent JSON?
2 spaces is the convention in JavaScript and most web projects and keeps deeply nested JSON narrower; 4 spaces is common in Python and Java codebases. JSON parsers ignore whitespace, so choose whatever your project's style uses. The formatter offers 2, 3 or 4 spaces and tabs.
Will formatting change my numbers?
No. The formatter copies every value exactly as written, so 9007199254740993 stays 9007199254740993 and 1.50 stays 1.50. Tools that run JSON through JavaScript's JSON.parse round integers above 9007199254740991 and rewrite numbers in their shortest form. When your JSON has numbers that large, a note under the panes points them out, because other JavaScript code that reads the JSON may round them.
What is the difference between formatting and minifying JSON?
Formatting adds indentation and line breaks to make JSON readable. Minifying removes all unnecessary whitespace to make it as small as possible for storage or transfer. Both produce the same data. Switch between Beautify and Minify above the panes; the JSON Minifier opens with Minify already selected.
What is a JSON file?
A plain text file, usually with the .json extension, that stores data in JSON (JavaScript Object Notation): objects in curly braces with "key": value pairs, arrays in square brackets, and strings, numbers, true, false and null, such as {"name": "Ada", "skills": ["math", "code"]}. Apps use it for configuration, such as package.json, and APIs use it to exchange data. Open it in any text editor, or open it here to format it.
Can I use this as a JSON formatter Chrome extension?
There is nothing to install: the formatter runs in any browser tab, including Chrome. Bookmark the page and paste JSON whenever you need it, with no extension permissions to grant.
Does the formatter check that my JSON is valid?
Yes. As you type, the input is checked with a strict RFC 8259 parser, and the status bar shows Valid JSON or the line and column of the first error. For a check that focuses on finding errors, use the JSON Validator.
Can it format large JSON files?
Yes. Open files or URL responses up to 50 MB, or paste large documents. The code view and the tree only render the rows on screen, so multi-megabyte JSON scrolls smoothly, and big inputs are re-checked once you pause typing. Nothing is uploaded; the practical limit is your browser's memory.
Can I format JSON from a URL?
Yes. Click Load URL and paste the address. Your browser requests it directly, so it works when the server allows other websites to read its responses (CORS), as many public APIs do. If the request is blocked, open the URL in a new tab, copy the JSON and paste it here.
Is this a JSON parser or JSON linter?
It does both jobs in one step. Your JSON is read with a strict RFC 8259 parser, which flags trailing commas, single quotes, unquoted keys, comments and duplicate keys, and reports the line and column of the first error in plain words. Valid JSON is then pretty-printed. For a check focused on errors, use the JSON Validator.
How do I open JSON in Excel?
Format the JSON here, then convert it to CSV and open the .csv file in Excel. Inside Excel you can also use Data > Get Data > From File > From JSON, which loads the data through Power Query. CSV works best when the JSON is a flat list of objects; deeply nested JSON needs flattening first.
How do I format JSON in VS Code, Notepad++ or IntelliJ?
VS Code: open the .json file and run Format Document (Shift+Alt+F on Windows, Shift+Option+F on macOS, Ctrl+Shift+I on Linux). Notepad++: install the JSON Viewer plugin from Plugins > Plugins Admin, then choose Plugins > JSON Viewer > Format JSON. IntelliJ IDEA and other JetBrains IDEs: Code > Reformat Code (Ctrl+Alt+L, or Cmd+Option+L on macOS).
Is my data safe?
When you request a URL, your browser sends the request directly to that destination. CodeUnpack does not proxy the request.
Does it work offline?
Once the page has loaded, you can work with local input offline. Loading a URL requires a connection.