Skip to main content
DevConverter
Home/Format Conversion/JSON Formatter / Minifier

JSON Formatter / Minifier

Beautify JSON with custom indentation, or minify it to a single line. Sorts keys optionally.

Indent

About this tool

JSON (JavaScript Object Notation) is a text-based data interchange format derived from JavaScript object literal syntax. It supports exactly six data types: objects (unordered key-value maps where all keys must be strings in double quotes), arrays (ordered sequences of values), strings (UTF-8 text in double quotes with specific escape sequences), numbers (no distinction between integers and floats; no special values like NaN or Infinity), booleans (the literal values true and false), and null. Any valid JSON document is one of these types at its root.

Pretty-printing JSON adds indentation and newlines to structure the data visually, making nested objects and arrays easy to read and compare. Indentation of 2 spaces is conventional in JavaScript ecosystems; 4 spaces is common in Python and Java. The sorted-keys option orders object keys alphabetically, which makes comparing two JSON objects easier and produces deterministic output from the same data regardless of insertion order.

Minifying JSON removes all whitespace that is not part of a string value — spaces, tabs, and newlines between tokens — producing the most compact valid representation. For a typical JSON API response, minification reduces size by 15–30%. At scale, this matters: a response that is 30% smaller reduces bandwidth costs proportionally and speeds up transmission, especially over mobile connections. All JSON parsers handle minified JSON identically to pretty-printed JSON.

Common JSON syntax errors: trailing commas after the last element of an array or the last property of an object (allowed in JavaScript, but not in JSON); single-quoted strings (JSON requires double quotes); comments (JSON has no comment syntax — if you need comments in config files, use JSONC, JSON5, or YAML instead); unquoted property keys (JSON always requires double-quoted strings as keys); and special numeric values like NaN, Infinity, and -Infinity (these are valid in JavaScript but not in JSON — use null or a string representation instead).

When working with JSON in different programming languages, watch for language-specific quirks. JavaScript's JSON.parse() silently loses precision for integers larger than 2^53 (Number.MAX_SAFE_INTEGER = 9,007,199,254,740,991), which is relevant when working with 64-bit integer IDs from databases. Python's json module parses JSON numbers to Python float or int correctly. Duplicate object keys in JSON are technically allowed by the spec but produce undefined behavior — different parsers keep the first, keep the last, raise an error, or produce an array. This formatter highlights structural issues to help catch these problems before they cause bugs in production.