Skip to main content

JSON Formatter

Available
JSON & Data

Format, validate, beautify, minify, inspect, transform, and analyze JSON instantly in your browser - with a tree view, JSON Path finder, duplicate-key detection, and smart error recovery.

JSON Formatter tool

How to use the JSON Formatter

  1. Paste JSON into the editor, open a file, or load one of the examples.
  2. If the JSON is valid it is formatted; if not, the error shows the line and column of the problem.
  3. Choose indentation, sort keys if you want, or minify the document to remove whitespace.
  4. Use the tree view to explore nested data and copy the path to any value.
  5. Copy or download the result.
What you enter
A JSON document: an object, an array, or a single value such as a string or number.
What you get
Formatted or minified JSON, validation results with exact error positions, a tree view with JSON paths, statistics about the document, and any duplicate keys found.

Who it is for

  • Developers reading API responses and webhook payloads
  • Engineers editing JSON configuration files
  • QA and support staff checking what a service returned

Examples

Minified to formatted

{"id":7,"name":"Ada","roles":["admin","dev"],"active":true}

The same data on separate indented lines: id, name, a roles array with two items and active set to true. Nothing about the data changes, only whitespace.

A trailing comma

{"a": 1, "b": 2,}

Reported as invalid at the closing brace, because JSON does not allow a comma after the last member. Remove the comma and it validates.

Single quotes

{'name': 'Ada'}

Reported as invalid at the first quote. JSON requires double quotes for strings and for keys.

Key concepts

The six JSON value types
A value is an object (key-value pairs in braces), an array (an ordered list in brackets), a string in double quotes, a number, true or false, or null.
Syntax rules people trip over
Keys must be strings in double quotes. No trailing commas. No comments. Numbers cannot have leading zeros, and NaN or Infinity are not allowed. A string cannot contain a raw line break; use \n.
Formatting versus minifying
Pretty printing adds indentation and line breaks for people. Minifying removes them to save bytes. Both represent exactly the same data.
Duplicate keys
The specification says keys should be unique, and parsers disagree about what to do when they are not: many keep the last one, others keep the first. The tool lists duplicates so the ambiguity does not surprise you.

Common use cases

  • Make a minified API response readable while debugging.
  • Find the exact character that makes a config file invalid.
  • Minify a payload before embedding it in a request or a script.
  • Find the path to a value, such as data.items[2].id, for use in code.

Common mistakes

Copying JavaScript object literals
Unquoted keys, single quotes and trailing commas are valid in JavaScript but not in JSON.
Adding comments to JSON config
Standard JSON has no comments. If a tool accepts them, it is using an extension.
Pasting a partial document
Copying only a middle section of a response leaves unbalanced braces and brackets.
Trusting a recovery suggestion blindly
Automatic fixes for common errors are guesses. Check that the repaired document still means what you intended.

Limitations

  • Very large documents can slow the browser, so the tool is best suited to everyday payloads rather than huge data dumps.
  • It validates syntax. It does not check data against a JSON Schema or know whether the values make sense for your API.
  • Numbers beyond JavaScript's safe integer range can lose precision in any browser-based tool.

Results are an aid, not a guarantee. Please read the Disclaimer.

Troubleshooting

It says my JSON is invalid but it looks fine
Look at the reported line and column. Common causes are a trailing comma, smart quotes copied from a document, or an invisible character.
The formatted output is very long
Use the tree view to collapse sections, or minify if you only need to move the data.
Keys moved around
Sort keys is off by default. If you turned it on, switch it off to keep the original order.

Privacy

Parsing, formatting and validation run in your browser. The JSON you paste is not sent to DevCraftKit. Full details are in the Privacy Policy.

Related guides

Did this JSON cleanup save you some time?

If these free developer tools save you time, consider buying me a byte. Your support helps keep DevCraftKit free and growing.

Buy me a byte ๐Ÿ’พ

Resources

View all

Explore more developer tools

Browse the full collection, or see everything in JSON & Data.

Frequently Asked Questions

What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data format used to represent structured data as key-value pairs, arrays, and nested objects. It's the standard format for exchanging data between web APIs, configuration files, and most modern applications, because it's both human-readable and easy for machines to parse.
How do I format JSON?
Paste or type your JSON into the editor above and click Format (or press Ctrl/Cmd+Enter). The formatter checks the syntax and re-indents the text without changing any values, making nested structure easy to read - it also works automatically if you enable Auto Format in Settings.
How do I validate JSON?
Validation runs automatically as you type - a Valid or Invalid badge appears above the editor. If it's invalid, you'll see the exact line, column, and a plain-English description of what's wrong, plus one-click suggested fixes for common mistakes.
What causes invalid JSON?
The most common causes are trailing commas after the last item in an object or array, using single quotes instead of double quotes, missing quotes around object keys, missing commas between items, and unescaped special characters inside strings. This tool detects each of these and can suggest a fix.
How do I minify JSON?
Click Minify (or press Ctrl/Cmd+Shift+M) to strip all whitespace, newlines, and indentation, producing the smallest JSON that is token-for-token identical to your input - useful for reducing payload size before sending data over a network.
Can JSON contain comments?
No - the JSON specification does not support comments. If you paste JSON containing // or /* */ comments (common in JSON5 or JSONC config files), it will fail validation. Remove comments before working with strict JSON.
Why is my JSON invalid even though it looks correct?
The most common invisible culprits are a trailing comma after the last property, smart/curly quotes introduced by a word processor instead of straight double quotes, an invisible byte order mark (BOM) at the very start of pasted text, or a stray character copied in from elsewhere. The validator's line and column reference points to the exact spot to check.
Does formatting or minifying change my numbers, strings, or keys?
No. Only whitespace between tokens changes. Numbers keep their exact text (12345678901234567890, 1.0, 1e+10, -0 and 1E400 stay as written, even though JavaScript's JSON.parse would round, rewrite, or overflow them), strings keep their escape sequences (\u00e9 stays \u00e9), and object members keep their original order. The one exception is the Sort Keys action, which reorders object members by key name - and even then values and duplicate keys are kept.
What happens to duplicate keys?
They are kept, in their original order, when you format, minify, or sort, and a Duplicate keys panel lists where they occur. The JSON standard says names should be unique, and parsers disagree: JavaScript's JSON.parse and Python's json module keep the last value, some parsers keep the first, and some reject the document. If the duplicates are not intentional, remove the ones you do not want.
How large of a file can I format?
File uploads are limited to 15 MB. Pasted text has no fixed limit in the tool itself, so the practical ceiling is your browser's memory, and the tree view is the slowest part for very large documents. Everything runs in your browser rather than on a server. Nesting deeper than 1,000 levels is rejected with an explicit error.
How do I pretty-print JSON?
Pretty-printing is the same as formatting - it means re-indenting JSON with line breaks and spacing so nested structure is readable. Use the Format button, and choose 2 spaces, 4 spaces, or a tab as your indentation in Settings.
Does this tool send my JSON to a server?
No. Parsing, formatting, validation, and every other feature run entirely in your browser using JavaScript - your data is never uploaded or transmitted anywhere.

Found a bug or an incorrect result in JSON Formatter?

Report it, or suggest an improvement. Messages go straight to the developer.

Send feedback