JSON Formatter
Pretty-print or minify JSON, see errors by line and column, and auto-fix trailing commas or single quotes. Nothing you enter is sent to a server.
Input
Fixes only comments, single quotes, unquoted keys and trailing commas. Your input stays as is; only the result changes.
Result
Your result will appear here
Format JSON to inspect its structure and save it as a file.
User reviews
No reviews yet. If you’ve used this tool, be the first to leave one.
JSON Formatter: complete guide
Walk through the steps and examples, or jump straight to the topic you need.
At a glance
- Supported syntax
- Standard JSON. Besides objects and arrays, strings, numbers, true, false, and null are handled when they are valid JSON values.
- Actions
- 2-space, 4-space, and tab indentation, plus one-line minifying.
- Input limit
- Up to 100,000 characters; UTF-8 files up to 512 KB.
- Formatting limit
- Indented formatting supports up to 128 levels of nesting and 2 million characters of output.
- What is preserved
- Long numbers, key order, duplicate keys, and string escapes are left as they are; only structural whitespace is tidied.
How to use JSON Formatter
Enter the JSON text
Paste the JSON part of an API response or config file. If you include markdown code block fences or a JavaScript variable declaration, it is not JSON syntax. You can also load a file when the source is empty.
Choose whether to format for readability or minify
To read the structure, choose formatting and an indentation. If you need data without line breaks, choose one-line minifying. Even when minified, whitespace and line break escapes inside string values are not removed.
Run it and check the error or the result
Run it with the convert button or Cmd/Ctrl+Enter. If an error appears, check the double quotes, trailing comma, and closing brackets. The original and the result are in separate areas so you can compare the changed whitespace.
Copy or save as a JSON file
Move the result to the editor or request tool you need. Changing the input or indentation invalidates the previous result, so run it again. Passing the syntax check does not mean the fields required by the target API are correct.
What it’s good for
JSON formatting and one-line minifying
Paste an API response or a config file and choose the indentation. It supports 2-space, 4-space, and tab formatting, plus one-line minifying. Whitespace inside strings is kept; only the whitespace between structural elements changes. You can compare the result next to the original and save it as a JSON file.
Syntax checking and preserving original values
Invalid JSON gets an error message when you run it. Check the double quotes around property names, any comma after the last item, and closing brackets. Long numbers, key order, and escape notation inside strings are preserved exactly as written. A pass means the syntax is valid; it does not check against the JSON Schema of a particular API.
Worked examples
Format an object with 2-space indentation
{"name":"UtilPick","active":true}{
"name": "UtilPick",
"active": true
}Preserve a long number and string whitespace
{ "id": 9007199254740993, "label": "a b" }{"id":9007199254740993,"label":"a b"}Choosing between formatting and minifying
Swipe the table sideways to see the rest.
| Method | Purpose | What is kept and limits |
|---|---|---|
| 2 or 4 spaces | Reading an API response or config structure | Only the indentation width changes; the original values and key order stay the same. |
| Tab | Editing environments that use tab indentation | The tab width you see depends on your editor settings. |
| One-line minify | Moving data without unnecessary structural whitespace | Whitespace inside strings is kept. Comments, single quotes, and trailing commas are fixed only when you press format after fixing them. |
When the result isn’t what you expected
It says my copied response is not JSON
The response may be an HTML error page, or explanatory text may be attached before or after the JSON. Keep only the actual JSON value. A JavaScript object containing single quotes, comments, or a trailing comma differs from standard JSON.
Fixing near the error position still fails
The error position can be near where the cause was first detected. Also look for a missing closing quote or bracket earlier in the text. This tool does not arbitrarily fix the syntax and change values, so edit the original and run it again.
It says it is too deep or the result is too large
When nesting is deep, indentation alone makes the output grow a lot. Format the needed parts separately, or choose one-line minifying. The input itself must also be within 100,000 characters.
Key terms
- Indentation
- Putting spaces or tabs at the start of a line to show nested structure.
- Escape
- Writing quotes, line breaks, and similar characters inside a string with backslash notation.
- JSON Schema
- A set of rules describing the requirements of data, such as field names and types. This tool does not check against those rules.
JSON Formatter FAQ
Does it support JSON with comments or single quotes?
It checks with standard JSON syntax and tells you where the error is. For comments, single-quoted strings, unquoted keys, and a comma before a closing bracket, press format after fixing them and it converts to standard JSON and tells you how many places were fixed. The original text is left as it is. Other JSON5 syntax is not supported.
Are big numbers rounded or keys sorted?
This formatter uses the original tokens to preserve number notation and key order. It does not reorder keys alphabetically or remove duplicate keys.
Can it format large or deeply nested JSON?
Input up to 100,000 characters is supported. Indented formatting is limited to 128 levels of nesting and 2 million characters of output, and if you exceed that, you are advised to split the JSON or use one-line minifying.
Are duplicate keys merged into one?
Duplicate keys are not removed or merged; they are kept in the original order. Other programs may read duplicate keys differently, so check any unintended duplicates in the original.
Is a JSON file I load sent to a server?
The file contents are read and formatted in the browser. It does not call an API from a server or use any feature that stores the original text in an account.