JSON Formatter

Format, validate, and explore JSON — instantly in your browser.

Data
Input
Output

How to use the JSON Formatter

1
Paste your JSON into the input panel on the left. You can paste minified, partially formatted, or raw API responses.
2
Choose your options: set the indent size (2 spaces, 4 spaces, or tab), optionally sort keys alphabetically, or switch to minify mode to compress the output.
3
Click "Format JSON" or start typing — the output panel updates automatically. If there is a syntax error, a red error message appears below the input with the exact line and column.
4
Copy the result using the Copy button above the output panel, or the "Copy result" button below the widget. A toast notification confirms the copy.
5
Nothing is sent to a server. All processing happens in your browser — safe to use with API keys, authentication tokens, and production data.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. Introduced as part of JavaScript in the early 2000s and standardised as RFC 8259, JSON has become the de facto standard for REST API responses, configuration files, and data storage across virtually every programming language and platform.

Despite its name, JSON is language-agnostic. Python, Ruby, Go, Java, Swift, PHP, Rust — all have native or standard-library JSON parsers. The format's simplicity is its key strength: it has only six value types (string, number, boolean, null, object, and array), a predictable syntax, and no ambiguity about encoding when UTF-8 is used.

A JSON object is a collection of key-value pairs enclosed in curly braces. Keys must be strings (double-quoted), and values can be any of the six types. Arrays are ordered lists enclosed in square brackets. This recursive structure lets JSON represent arbitrarily complex hierarchical data in a compact, readable form.

The challenge JSON formatters solve is that parsers and APIs produce minified JSON — all whitespace stripped to minimize bytes transferred. Minified JSON is efficient for machines but nearly unreadable for humans. Formatting (or "pretty-printing") JSON adds consistent indentation and newlines, making the hierarchy immediately visible without changing the data in any way.

JSON syntax quick reference

TypeSyntaxNotes
String"hello world"Double quotes only. Escape with \", \\, \n, \t
Number42   3.14   -7   1e10No octal/hex literals. No trailing decimal.
Booleantrue   falseLowercase only (not True or TRUE)
NullnullLowercase only. Represents intentional absence of value.
Object{"key": "value"}Keys must be double-quoted strings. No trailing comma.
Array[1, "two", true]Can mix types. No trailing comma after last item.
Nested{"a": {"b": [1, 2]}}Objects and arrays can nest to any depth.

Examples

Example 1: Minified API response → formatted

Input (minified)
{"id":1,"name":"Ada Lovelace","role":"developer","active":true,"scores":[98,87,95]}
Output (2-space indent)
{ "id": 1, "name": "Ada Lovelace", "role": "developer", "active": true, "scores": [ 98, 87, 95 ] }

Example 2: JSON with a syntax error

Input (invalid — trailing comma)
{ "name": "ToolsPack", "version": "1.0", }
Error output
SyntaxError: Unexpected token } in JSON at position 42 → Trailing commas are not allowed in standard JSON. Remove the comma after "1.0" on line 3.

Common JSON mistakes

  • Trailing commas — JSON does not allow a comma after the last item in an object or array. This is the single most common mistake, especially when editing by hand.
  • Single quotes — All strings, including keys, must use double quotes. Single quotes are valid JavaScript but not valid JSON.
  • Unquoted keys — In JavaScript object literals you can write {name: "value"}, but in JSON every key must be a double-quoted string: {"name": "value"}.
  • Comments — Standard JSON does not support comments (// comment or /* comment */). If you need comments in config files, consider YAML, TOML, or the non-standard JSONC format understood by some tools.
  • Undefined and NaN — The JavaScript values undefined, NaN, and Infinity are not valid JSON. JSON.stringify() converts undefined values to null in arrays and omits them in objects.

Frequently asked questions

JSON formatting (also called pretty-printing) adds consistent indentation and line breaks to minified or unformatted JSON, making it human-readable without changing the data. The tool parses your JSON and then re-serializes it with the chosen indent size.

Yes. The JSON Formatter runs 100% in your browser using JavaScript. No data is ever sent to any server. You can verify this by opening your browser's DevTools Network tab and observing that no requests are made while you type or format. Your data stays on your machine.

The most common causes are: trailing commas after the last item in an object or array, single quotes instead of double quotes around strings or keys, unquoted keys (valid in JS but not JSON), missing commas between items, and comments (which JSON does not support). The error message includes the exact character position to help you pinpoint the issue.

JSONC (JSON with Comments) is a non-standard superset of JSON used by tools like VS Code's settings.json. It allows // single-line and /* multi-line */ comments. Standard JSON parsers — including this formatter — will reject JSONC files containing comments. Use a dedicated JSONC parser or strip comments before processing.

Yes, up to several megabytes without issue in modern browsers. Very large files (50 MB+) may slow down the browser tab because the entire file must be held in memory and rendered as text. For files that large, a local tool like jq (a command-line JSON processor) or a code editor with a JSON plugin is a better choice.

Two spaces is the most common convention for JSON files in JavaScript and Node.js projects. Four spaces is common in Python and Java communities. The choice is purely a style preference — JSON itself specifies no indentation. If you're contributing to an existing project, match whatever the project already uses.