JSON Tools
JSON Formatter
Format and validate JSON in your browser with clear, readable indentation.
Input stays in this browser while you use the tool.
About this tool
The JSON Formatter rewrites JSON text with consistent indentation and line breaks so that it is easy to read. A compact response copied from an API, a browser's network tab or a log file becomes a structured document in which every object and array is visible at a glance.
JSON (JavaScript Object Notation) is a plain-text format for structured data. It is built from objects in curly braces, arrays in square brackets, and values that are strings, numbers, true, false or null. Formatting does not change the data itself. It only changes the whitespace between the tokens, which JSON ignores outside of strings.
Because the tool parses your text before rewriting it, it also reports input that is not valid JSON. That makes it useful both for reading data and for catching a stray comma or quote before the data goes into a request, a config file or a test fixture.
The formatter runs in your browser, so the JSON you paste is processed on your own device and is not sent to the BitToolsKit server.
Use cases
- Read an API response. Servers often return JSON on a single line to save bytes. Formatting it shows the nesting so you can find the field you need.
- Check a hand-edited config file. Files such as
package.jsonortsconfig.jsonbreak easily when a comma or quote is missed. Paste the file to confirm it still parses. - Prepare examples for documentation or bug reports. Indented JSON is much easier for teammates to read in a ticket, a code review or a tutorial.
- Understand unfamiliar data. A formatted view makes it easier to spot nested levels, repeated structures, missing fields and unexpected null values.
- Debug a request body. If an API rejects your payload, formatting it first shows whether the problem is the JSON itself or the values inside it.
- Prepare two payloads for comparison. Format both with the same layout, then compare them line by line with a text diff tool.
How to use
- Paste your JSON into the Input box. You can paste an object, an array or a single value.
- Click Run tool.
- Read the result in the Output box. Each nested level is indented, with one key or array item per line.
- If the input is not valid JSON, a message appears under the output box. Read it, correct the input and run the tool again.
- Click Copy output to copy the formatted JSON, or Download to save it as a file.
- Click Clear to empty the boxes before starting with new data.
If an error message mentions a position, or a line and column, count from the start of the input to find the problem. The exact wording of the message depends on your browser.
Examples
Example 1: Minified object
Input:
{"id":101,"name":"Ada","roles":["admin","editor"],"active":true}Output:
{
"id": 101,
"name": "Ada",
"roles": [
"admin",
"editor"
],
"active": true
}Example 2: Nested order with an array of objects
Input:
{"order":{"id":"A-1001","items":[{"sku":"X1","qty":2},{"sku":"Y9","qty":1}],"paid":false}}Output:
{
"order": {
"id": "A-1001",
"items": [
{
"sku": "X1",
"qty": 2
},
{
"sku": "Y9",
"qty": 1
}
],
"paid": false
}
}Example 3: Invalid JSON with a trailing comma
Input:
{"name":"Ada","age":30,}Output: No formatted result. An error message appears under the output box. Remove the comma after 30 and run the tool again.
Common errors
Trailing comma after the last item, such as {"a":1,}
Remove the comma after the last key or array item. JSON does not allow it, even though many programming languages do.
Single quotes around keys or strings
Replace single quotes with double quotes. Valid JSON only accepts double quotes.
Unquoted keys, such as {name: "Ada"}
Wrap every key in double quotes: {"name": "Ada"}. JavaScript object literals allow bare keys, JSON does not.
Comments inside the JSON
Delete anything written as // or /* */. Standard JSON has no comments. Formats like JSONC and JSON5 allow them, but this tool expects strict JSON.
Missing comma between two items
Add a comma between every pair of keys or array items. Error messages usually point just after the place where the comma is missing.
Unescaped double quote or line break inside a string
Write a quote inside a string as \" and a line break as \n. A raw line break inside a string is not valid.
Unmatched brackets or braces
Count that every { has a closing } and every [ has a closing ]. Formatting a smaller part of the data first can help you find the missing one.
Values that JSON does not support, such as undefined, NaN, Infinity or a number like 007
Use null for missing values and write numbers without leading zeros. Values such as NaN and Infinity are not valid JSON.
Extra text before or after the JSON, or curly quotes copied from a document
Remove labels such as Response: and replace curly quotes with straight double quotes. Text copied from word processors often contains curly quotes.
A very long number changes after formatting
Numbers larger than 9007199254740991 can lose precision when parsed as JavaScript numbers. If the exact digits matter, store the value as a string in the source data.
Frequently asked questions
What does a JSON formatter do?
It adds indentation and line breaks to JSON so the structure is easy to read. The data stays the same. Only the whitespace between the tokens changes.
Does formatting change my data?
It does not add or remove keys or values. Two edge cases are worth knowing: if the same key appears twice in an object, JavaScript parsers keep the last value, and integers larger than 9007199254740991 can lose precision.
Is my JSON uploaded to a server?
No. The tool runs in your browser and processes the text on your device. As a general habit, avoid pasting passwords, API keys or private tokens into any online tool.
What is the difference between formatting, validating and minifying?
Formatting adds whitespace to make JSON readable. Validating checks whether the syntax is correct. Minifying removes whitespace to make the text smaller. This tool formats and reports syntax errors, while the JSON Validator and JSON Minifier focus on those individual tasks.
Why does my JSON show an error?
The most common causes are a trailing comma, single quotes, unquoted keys, comments and missing brackets. See the common errors section above for how to fix each one.
Does it accept comments or trailing commas?
No. The tool expects strict JSON, which does not allow either. Formats such as JSON5 and JSONC do, so remove comments and trailing commas before pasting.
Why did a long number change after formatting?
Numbers are read as JavaScript numbers, which can hold integers exactly only up to 9007199254740991. Larger values can be rounded. If you need every digit, keep the value as a string in the source data.
Can I format very large JSON?
Very large inputs can be slow because all of the work happens in your browser, and a multi-megabyte file may freeze the tab for a moment. For huge files, a command-line tool such as jq is a better fit.
Does it work on a phone or tablet?
Yes. The tool works in current mobile browsers. For long JSON, a larger screen makes the output easier to read.