T

Text Machine

Powerful text tools, in your browser

JSON Formatter

Beautify, validate and minify JSON in your browser. Paste your data, choose an indentation style, and get clean, readable output instantly — nothing is uploaded.

Input JSON

0 lines · 0 chars

Indent

How to use JSON Formatter

  1. 1

    Paste your JSON

    Paste minified, messy, or already-indented JSON into the input panel.

  2. 2

    Choose indentation

    Select 2 spaces, 4 spaces, or tabs to control how the beautified output is indented.

  3. 3

    Format or minify

    Click 'Format' to pretty-print and validate the JSON, or 'Minify' to compact it into a single line.

  4. 4

    Copy the result

    Use the 'Copy' button to grab the formatted or minified output for your project.

Working with JSON: Formatting, Validation, and the Mistakes That Bite

What JSON actually is

JSON (JavaScript Object Notation) is a text-based data-interchange format that has become the default way services talk to each other over HTTP. Despite the name, it is language-independent: parsers exist for every mainstream language, and the wire format is just UTF-8 text. A document is built from exactly six value types — objects (unordered key/value collections), arrays (ordered lists), strings, numbers, the booleans true and false, and null. Everything you serialize, from an API response to a config file, decomposes into those six.

Two rules trip people up constantly. First, keys in an object must be double-quoted strings — bare identifiers are not allowed, unlike JavaScript object literals. Second, JSON has no integer versus float distinction and no comment syntax. A number is just a number, and any human notes you want to leave have to live inside a string value or be stripped before parsing.

Formatting versus minifying

These are two views of the same data. Formatting (also called beautifying or pretty-printing) inserts newlines and indentation so the nesting is visible at a glance — this is what you want while reading a payload, diffing two responses in version control, or pasting an example into documentation. Minifying does the opposite: it removes every byte of insignificant whitespace to produce one compact line, which is what you ship over the network where each kilobyte costs latency and bandwidth.

Both directions are lossless for the data itself. Whitespace between tokens is never significant in JSON, so collapsing a 40-line object to a single line and expanding it again yields identical parsed values. The only thing that changes is byte count and readability, which is exactly why this tool offers both buttons rather than forcing one style.

The syntax errors you will actually hit

The single most common error is the trailing comma — a comma after the last element of an array or the last pair of an object. JavaScript tolerates it; JSON forbids it, so a list that ends with a comma before the closing bracket will fail to parse. Right behind it are single quotes instead of double quotes (JSON strings must use double quotes) and unquoted keys copied straight out of JavaScript source.

Other frequent culprits: a stray comment (// or block style), which is valid in JSONC and JSON5 but not in strict JSON; values like NaN, Infinity, or undefined, which simply do not exist in the spec; and unescaped control characters such as a literal tab or newline inside a string. When the validator points at a line, scan a character or two before the highlighted position — the parser often only notices the problem at the next token after the real mistake.

Choosing an indentation style

Two spaces is the de facto standard for JSON on the web and the default emitted by most tooling, including many linters and formatters. Four spaces reads more spaciously for deeply nested structures, and tabs let each developer pick their own on-screen width while keeping the file byte-identical. The right answer is whatever your repository already uses; mixing styles within one project produces noisy, meaningless diffs.

Indentation is purely cosmetic and is discarded the moment the document is parsed, so it never affects correctness. Pick a width, apply it consistently, and let the formatter normalize anything pasted in from another source.

Key order and data integrity

This formatter re-indents and re-spaces your document but does not reorder keys or alter any value. That matters because, although the JSON specification defines objects as unordered, virtually every real parser preserves insertion order, and downstream consumers — snapshot tests, signed payloads, human reviewers reading a diff — often depend on it. A tool that silently sorted keys could break a signature check or bury a one-line change in a hundred-line reshuffle.

If you do want canonical, sorted output for stable diffs or content hashing, that is a deliberate, separate operation you should opt into knowingly — not a side effect of pretty-printing. Keeping format and reorder distinct means you always know exactly what changed.

Numbers, precision, and Unicode

JSON numbers are decimal and have no declared size limit, but the JavaScript engine that parses them in your browser stores them as 64-bit floating point. That means integers larger than about nine quadrillion (the safe-integer ceiling) can lose precision on a round trip, which is why large IDs, snowflake values, and money amounts are often transmitted as strings instead of raw numbers. If exactness matters, quote the value.

Strings are full Unicode. You can write characters directly as UTF-8 or as backslash-u escape sequences, and both forms parse to the same code points. Because the format is UTF-8 text end to end, accented letters, non-Latin scripts, and emoji survive formatting and minifying untouched.

Everything stays in your browser

All parsing, validation, and re-serialization run locally in JavaScript. Nothing you paste is uploaded, logged, or stored on a server, so it is safe to format API responses that contain access tokens, internal identifiers, or customer data. The practical ceiling is your device's memory rather than any upload limit, so large exports format fine on a reasonably specced machine.

A useful habit: when an integration misbehaves, paste the raw response here first. Confirming the payload is well-formed JSON before you blame your code separates a serialization bug from a parsing bug in seconds, and it does so without leaking the payload anywhere.

Frequently asked questions

What is the difference between Format and Minify?
Format (beautify) adds line breaks and indentation so the structure is easy to read, while Minify strips all unnecessary whitespace to produce the smallest possible single-line JSON for production payloads.
Does the formatter validate my JSON?
Yes. If the JSON is invalid, it shows an error highlighting where the problem is instead of producing output, so you can quickly locate the missing comma, bracket, or quote.
What indentation options are available?
You can format with 2 spaces, 4 spaces, or tab characters, letting you match your team's or project's coding style.
Does it reorder my keys or change the data?
No. It only re-indents or compacts the existing structure. Key order and all values are preserved exactly as they appear in your input.
Is my JSON uploaded, and can it handle large files?
Nothing is uploaded. The formatter runs entirely in your browser, so it is safe for sensitive data, and it can handle large documents limited only by your device's available memory.

Related tools

Keep going with these handy tools

HTML Compressor

HTML to Text Converter

Regex Tester

JWT Decoder

CSS Gradient Generator

CSS Box Shadow Generator