Skip to main content

DigitalCalculators.net

JSON Formatter

Last updated By the DigitalCalculators.net team Free, no sign-up

Paste JSON to format it with clean indentation, check that it is valid, or minify it into one line. Errors show the line and column.

Results

Formatted JSON
ItemValue
JSON is checked with your browser’s built-in parser, which follows the JSON standard (ECMA-404 and RFC 8259). Comments, trailing commas and single quotes are not valid JSON. Your data stays in your browser.

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.

Last updated: 15 November 2026 ·How we calculate this: how JSON is checked

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

  1. Paste your JSON into the box.
  2. Choose the indentation or Minify.
  3. Choose whether to sort keys.
  4. Press Format and read any error message.
  5. Press Copy to copy the result.

How JSON Is Checked

  • Objects: curly braces with "key": value pairs 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.

TypeExample
String"hello"
Number42 or 3.14
Booleantrue or false
Nullnull
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

SourceUsed ForLink
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
Cite or share this calculator

DigitalCalculators.net. (2026, November 15). JSON Formatter. https://digitalcalculators.net/json-formatter/