PureDevTools

JSON Formatter & Beautifier

Format, minify, sort keys, and validate JSON — all in your browser, nothing sent to any server

All processing happens in your browser. No data is sent to any server.
Indent:
Formatted Output

Formatted JSON will appear here.

You copy a JSON response from curl — one line, 2000 characters, no formatting. You need to see the structure: is data an array or an object? Is the error field present? You could pipe through jq . in the terminal, but you’re already in the browser and just want to paste, format, and read.

Why This Formatter (Not the JSON Formatter & Validator)

PureDevTools has two JSON formatting tools. This one is simple and fast — paste JSON, pick indentation (2-space, 4-space, tab), get formatted output with syntax highlighting. The JSON Formatter & Validator adds validation with error location, key sorting, and statistics. Use this tool for quick formatting; use the other when you need diagnostics.

What Is a JSON Formatter and Why Does It Matter?

JSON (JavaScript Object Notation) has become the universal language of data on the web. Every developer works with it daily — reading API responses, editing configuration files, scanning application logs, and building request payloads. But JSON generated by programs or transmitted over networks arrives compacted into a single dense line that is nearly impossible to read. A string like {"user":{"id":42,"name":"Alice","roles":["admin","editor"]},"ts":"2024-01-15T09:23:00Z"} tells you almost nothing about its own structure at a glance.

A JSON formatter — also called a JSON beautifier, JSON pretty printer, or JSON indenter — solves this problem instantly. It parses the compact text and re-serializes it with clean, hierarchical indentation that exposes the shape of your data: which keys belong to which objects, how deeply arrays are nested, and where each value lives in the tree. One click turns a wall of minified text into a readable, navigable document.

This tool handles four operations that developers use every day:

Everything runs in your browser using native JavaScript — no data ever leaves your device.

JSON Beautifier vs JSON Minifier

These are two opposite operations on the same data:

JSON beautifier (the Format button) expands compact JSON by adding newlines and indentation. It makes JSON easy to read, inspect, and debug, but increases file size. Use it during development, debugging, and code review.

JSON minifier (the Minify button) strips all unnecessary whitespace — spaces, tabs, and newlines — from a JSON document to produce the smallest valid JSON string. This reduces payload size for API responses, configuration files, and data stored in databases. Use it before committing production configurations or shipping data over the network.

Example — the same JSON before and after formatting:

{"name":"Alice","age":30,"hobbies":["reading","coding"]}

After formatting with 2-space indentation:

{
  "name": "Alice",
  "age": 30,
  "hobbies": [
    "reading",
    "coding"
  ]
}

JSON Validator

The built-in JSON validator checks your JSON for syntax errors using the browser’s native JSON.parse function. When a problem is detected, the tool reports the exact line number and column where parsing failed — so you can jump directly to the problematic character without scanning the entire document.

Common JSON syntax errors include:

ErrorExampleFix
Missing comma{"a":1 "b":2}Add , after 1
Trailing comma{"a":1,}Remove the last ,
Unquoted key{name:"Alice"}Quote the key: {"name":"Alice"}
Single quotes{'name':'Alice'}Use double quotes: {"name":"Alice"}
Mismatched bracket{"a":[1,2}Change } to ]
Undefined / comments{"a": undefined}JSON does not support undefined or comments
Bare number root0123Leading zeros are not valid in JSON numbers
Unescaped control character{"msg":"line\none"}Use \\n escape sequence instead of a literal newline

Sort Keys Alphabetically

The Sort Keys feature recursively sorts all object keys in alphabetical order at every nesting level. Array element order is preserved — only object keys are sorted.

Sorting keys is useful for:

Common Use Cases

API development: Copy a JSON response from browser DevTools, Postman, Insomnia, or a curl command, paste it into the formatter, and instantly see the structure with syntax highlighting. Spot unexpected fields, missing keys, or wrong nesting immediately.

Configuration files: Format package.json, tsconfig.json, appsettings.json, .eslintrc.json, or any other JSON configuration file before committing to version control. Consistent indentation makes pull request reviews cleaner and reduces merge conflicts.

Log inspection: Application logs and event streaming systems often embed minified JSON payloads in log lines. Paste them here to inspect field values, trace IDs, error codes, and nested objects without straining your eyes.

Data validation before submission: Before sending JSON to an external API or storing it in a database, validate it here to catch syntax errors at your desk rather than debugging a 400 Bad Request at 2 am.

Comparing API responses: Format both responses, enable Sort Keys, then copy each into a diff tool. Sorted keys eliminate key-ordering noise so only real data changes appear in the diff.

Education and documentation: When writing API documentation or teaching JSON to junior developers, use the formatter to produce clean, consistently indented examples that are easy to read and copy.

Technical Reference

JSON Specification Compliance

This formatter implements the JSON grammar as defined in RFC 8259 (the current IETF standard, obsoleting RFC 7159 and the original RFC 4627) and ECMA-404 Second Edition (the Ecma International JSON Data Interchange Standard). These two documents are normatively equivalent and together define the canonical JSON specification used by all conforming parsers and generators worldwide.

Key specification rules this tool enforces:

What This Tool Does Not Support

FormatDescriptionWorkaround
JSON5Superset with comments, trailing commas, single-quoted strings, unquoted keysRemove non-standard syntax first
JSONCJSON with Comments, used in VS Code settings.json and tsconfig.jsonStrip // and /* */ comments before pasting
JSON Lines (JSONL / NDJSON)One JSON value per line, no wrapping arrayValidate and format each line individually
JavaScript object literalsundefined, NaN, Infinity, functionsConvert to valid JSON types first
BigIntJavaScript integers beyond 2^53 - 1 may lose precision in JSONUse string representation for large integers

Formatting Options Reference

OptionValuesDefaultNotes
Indentation2 spaces / 4 spaces / Tab2 spaces2-space matches Prettier, ESLint, and Google Style Guide; 4-space matches Python json.dumps(indent=4) and many Java/C# conventions; Tab is required when .editorconfig or team style mandates it
Sort KeysOn / OffOffAlphabetizes object keys recursively at all nesting levels; array element order is always preserved
OutputFormat / MinifyFormatMinify produces the smallest valid JSON with zero whitespace

Browser-Side Processing

All operations — parsing, formatting, minifying, key sorting, and validation — execute entirely within your browser using the built-in JavaScript JSON.parse and JSON.stringify APIs, plus custom recursive sort logic for the Sort Keys feature. No network request is made at any point. The tool works offline after the initial page load. For very large documents (above 5 MB), performance depends on your device’s CPU speed and available memory, not on any server.

Frequently Asked Questions

What is the difference between JSON and JavaScript objects?

JSON is a strict text serialization format derived from JavaScript object literal syntax, but it has important restrictions that make it a proper data interchange format rather than code. All keys must be double-quoted strings. Values must be one of the six JSON types: string, number, object, array, boolean, or null. Features valid in JavaScript object literals but forbidden in JSON include: single-quoted strings, unquoted keys, trailing commas, undefined, NaN, Infinity, comments, and functions. These restrictions ensure that any conforming JSON parser — in Python, Go, Java, or any other language — can read the same document.

Why does JSON use double quotes and not single quotes?

The JSON specification (RFC 8259, Section 7) explicitly mandates double-quoted strings. Single-quoted strings are syntactically valid in JavaScript object literals but not in JSON. This is one of the most common mistakes when writing JSON by hand. Most JSON parsers in all languages will reject single-quoted strings with a syntax error, so it is important to use double quotes consistently.

Why does my JSON fail validation even though it looks correct?

Several hidden issues can cause JSON to fail despite looking fine visually. Common culprits include: a Byte Order Mark (BOM) at the start of the file (added by some Windows text editors), invisible Unicode characters such as non-breaking spaces (U+00A0) or zero-width spaces (U+200B), unescaped newlines or tabs inside string values (they must be written as \n and \t), and copy-paste artifacts from Word or rich text editors that replace straight quotation marks with typographic curly quotes (" and "). If your JSON fails and you cannot see why, try re-typing the problematic section manually.

What is the maximum JSON file size this tool can handle?

The formatter runs entirely in your browser using JavaScript’s built-in JSON.parse and JSON.stringify. It can comfortably handle JSON documents well over 1 MB without noticeable delay on modern hardware. For very large files (5 MB or more), consider disabling syntax highlighting and using the Minify output to reduce rendering work. Documents above 50 MB may approach browser memory limits, in which case a command-line tool such as jq is more appropriate.

Can I format JSON with comments (JSON5 or JSONC)?

No. Standard JSON does not support comments. RFC 8259 is explicit on this point. This tool validates strictly against the JSON specification. If your file contains // line comments or /* block comments */ (common in VS Code settings.json and TypeScript configuration files), you must remove the comments before pasting. Some editors can strip JSONC comments automatically — in VS Code, use the JSON: Remove Comments command or save the file as .json after stripping comments.

What does “Sort Keys” actually do to my data?

Sort Keys reorders the keys inside every JSON object alphabetically, at every nesting depth, before formatting or outputting the result. It does not change any values or modify arrays in any way — only object key order changes. The resulting JSON represents exactly the same data as the input; only the textual ordering of keys is different. This is useful because JSON objects are defined as unordered collections by the specification, meaning two JSON documents with the same keys in different orders are semantically identical. Sorting makes this semantic equivalence visible in diffs and version control.

What is the difference between RFC 8259 and ECMA-404?

RFC 8259 is published by the Internet Engineering Task Force (IETF) and is the document most web developers refer to when they say “the JSON spec.” ECMA-404 Second Edition is published by Ecma International and is the document the JavaScript standards body maintains. Both documents define the same grammar and are normatively equivalent — they were deliberately aligned to be interchangeable references. The practical difference is context: RFC 8259 is the IETF standard (used in HTTP, network protocols), while ECMA-404 is the Ecma standard (used in ECMAScript/JavaScript specifications).

Why does JSON not allow trailing commas?

Trailing commas — a comma after the last element in an array or the last key-value pair in an object — are forbidden by the JSON specification. This was a deliberate design choice when JSON was formalized, prioritizing strict, unambiguous parsing over developer convenience. JavaScript object and array literals allow trailing commas (and modern style guides encourage them for cleaner diffs), but JSON parsers in most languages will reject them. This mismatch is why copying JavaScript object literals into a JSON context often fails immediately.

Is my JSON data sent to any server?

No. Every operation — formatting, minifying, sorting, and validating — runs entirely in your browser using JavaScript. The tool makes no network requests with your data. Your JSON document never leaves your device. This means the tool is safe for formatting sensitive JSON such as API authentication tokens, database records, private configuration values, or any internal business data.

Can I format a JSON array at the root level?

Yes. A root-level JSON array is perfectly valid per the JSON specification. RFC 8259 defines the root value as any JSON value — object, array, string, number, boolean, or null. Paste [1, 2, {"key": "value"}, null, true] and the formatter will indent it exactly as it does for objects. The common misconception that JSON documents must start with { comes from older APIs that always returned objects; the specification itself imposes no such restriction.

Related Tools

More JSON Tools