Quick Answer
Paste your JSON and press Format. Valid JSON is shown with neat indentation, and the table confirms it is valid and counts objects, arrays and keys. If the JSON is broken, you see the error with its line and column. Choose Minify to squeeze it onto one line.
Embed this calculator
Adjust the size if needed, then copy the code below into your page or blog. The calculator will load in an iframe and stay updated automatically.
Table of Contents
- JSON Formatter
- Quick Answer
- Related Calculators
- How This JSON Formatter Works
- How to Use the JSON Formatter
- How JSON Is Checked
- Key Terms
- Worked Example
- Real-Life Examples
- Formatted vs Minified JSON
- JSON Value Types
- Common JSON Errors
- Common Mistakes to Avoid
- Frequently Asked Questions
- References & Sources
How This JSON Formatter Works
JSON (JavaScript Object Notation) is the most common format for sending data between apps and websites. Minified JSON is hard to read, and one missing quote breaks it. Paste your JSON here to make it readable, check it, or shrink it.
Features:
- Format: indent with 2 spaces, 4 spaces or tabs.
- Validate: errors show where the problem is.
- Minify: remove spaces and line breaks.
- Sort keys: order object keys A to Z to compare files.
- Stats: objects, arrays, keys, nesting depth and size.
How to Use the JSON Formatter
- Paste your JSON into the box.
- Choose the indentation or Minify.
- Choose whether to sort keys.
- Press Format and read any error message.
- Press Copy to copy the result.
How JSON Is Checked
- Objects: curly braces with
"key": valuepairs separated by commas. Keys must be in double quotes. - Arrays: square brackets with values separated by commas.
- Values: strings in double quotes, numbers, true, false, null, objects or arrays.
- Not allowed: comments, trailing commas, single quotes, undefined, and numbers like 012 or NaN.
- Formatting: the parsed data is written back out with the indentation you choose.
Key Terms
- JSON: JavaScript Object Notation, a text format for data.
- Object: a set of key and value pairs in curly braces.
- Array: an ordered list in square brackets.
- Minify: remove spaces and line breaks to make data smaller.
Worked Example
Minified input: {"name":"Ada","skills":["math","code"]}
- Valid: yes. Top level is an object with 2 keys.
- Formatted with 2 spaces, it spreads over 7 lines, with skills on its own indented lines.
- Arrays: 1. Deepest nesting: 2 levels.
- Broken input
{'name':'Ada'}fails because JSON needs double quotes.
Real-Life Examples
- API responses: make a one-line response readable before debugging.
- Config files: check a settings file before you deploy it.
- Smaller files: minifying a 4,800-byte formatted file can save hundreds of bytes of spaces.
- Comparing data: sort keys in two files, then compare them line by line.
Formatted vs Minified JSON
- Formatted: easy for people to read and edit; larger files.
- Minified: smallest size for sending over networks; hard to read.
- Same data: both contain exactly the same values.
JSON Value Types
From the JSON standard, ECMA-404.
| Type | Example |
|---|---|
| String | "hello" |
| Number | 42 or 3.14 |
| Boolean | true or false |
| Null | null |
| Object | {"a": 1} |
| Array | [1, 2, 3] |
Common JSON Errors
- Trailing comma:
[1, 2, 3,]is invalid; remove the last comma. - Single quotes:
'name'must be"name". - Unquoted keys:
{name: 1}must be{"name": 1}. - Comments:
//and/* */are not allowed in JSON. - Missing brackets: every
{needs a}and every[needs a].
Common Mistakes to Avoid
- Trailing commas. Allowed in JavaScript, not in JSON.
- Single quotes. JSON strings use double quotes only.
- Comments. Remove them before parsing.
- Pasting JavaScript. Functions and undefined are not JSON.
- Large numbers. Numbers beyond 2 to the power 53 can lose precision in browsers.
Frequently Asked Questions
Paste it and press Format. Choose 2 spaces, 4 spaces or tabs.
Paste it and press Format. The table says Valid JSON: Yes, or an error shows where it breaks.
Choose Minify (one line) under Output.
Common causes are trailing commas, single quotes, unquoted keys and comments.
Yes. Choose Sort keys A to Z.
No. It is parsed in your browser.
No. Standard JSON does not allow comments.
JSON is text with strict rules: double quotes, no functions and no trailing commas. JavaScript objects are more flexible.
Several megabytes usually work; very large files depend on your device's memory.
Browsers word JSON errors in different ways. The tool shows the line and column when your browser reports a position.
Pretty printing adds line breaks and indentation so each key and value sits on its own line. The data does not change, only the layout, which makes nested objects much easier to read.
All three are valid JSON. Many web projects use 2 spaces to keep lines short, while some teams prefer 4 spaces or tabs. Follow whatever style your project or team already uses.
No. The values stay the same; only the order of keys inside each object changes. JSON objects have no required key order, although some programs may expect a certain order for readability.
Minified JSON has no extra spaces or line breaks, so files are smaller and load faster over a network. It is common for API responses and for data embedded in web pages.
References & Sources
| Source | Used For | Link |
|---|---|---|
| Ecma International, ECMA-404 The JSON Data Interchange Syntax | JSON grammar and value types. | https://ecma-international.org/publications-and-standards/standards/ecma-404/ |
| IETF RFC 8259, The JSON Data Interchange Format | JSON rules for data exchange. | https://www.rfc-editor.org/rfc/rfc8259 |
DigitalCalculators.net. (2026, November 15). JSON Formatter. https://digitalcalculators.net/json-formatter/