</> Online Utilitiesdev.conversiontools.online

JSON Formatter — beautify & pretty-print JSON

Paste minified or messy JSON and watch it reformat instantly with clean indentation — 2 spaces, 4 spaces or tabs — plus optional A–Z key sorting, syntax highlighting and a collapsible tree view. Invalid JSON gets a precise error with the exact line and column, and Minify compresses it back to a single line whenever you need it small.

Try an example

One click loads a realistic payload and formats it — a starting point for testing, diffing or learning the syntax.


    
    
Send formatted JSON to…

The current formatted output travels in the link itself. Very long payloads are copied to your clipboard instead, ready to paste into the next tool.

Your session

Snapshots and pinned setups live only in this tab's memory — close or reload the page and they are gone, so your JSON is never stored. The tools rail remembers only which tools you opened in this tab (session storage, no JSON data).

Format history

  • No snapshots yet — format valid JSON and it will appear here.

Favorite setups

  • No pinned setups yet. Pin the current indent, key order and view to reuse them in one click.

Favorite tools

  • Pin a tool below and it will appear here.

Recently used

  • No other tools used yet this session — tools you open from this page will appear here.

All encoding & conversion tools

    How to format JSON

    1. Paste your JSON into the box, or use Open .json file to load one from your device — the file is read locally, never uploaded.
    2. The formatter validates and pretty-prints it instantly. Pick 2 spaces, 4 spaces or Tab indent, and optionally Sort keys A–Z.
    3. Copy the result, download it as a .json file, explore it in the Tree view, or press Minify to compress it back to one line.

    Worked example

    This 62-character minified input:

    {"name":"Ada","age":36,"skills":["math","code"],"active":true}

    formats with 2-space indent to 92 characters across 9 lines:

    { "name": "Ada", "age": 36, "skills": [ "math", "code" ], "active": true }

    The stats under the tool report 4 keys · 1 object · 1 array · 3 strings · 1 number · 1 boolean · 0 nulls · max depth 2 (depth counts nested objects and arrays, with the root at level 1). Pressing Minify returns exactly the original 62 characters — formatting and minifying are both lossless. With Sort keys A–Z, {"b":1,"a":2} becomes {"a": 2, "b": 1} order at every nesting level.

    What formatting changes — and what it never does

    AspectEffect of formatting
    WhitespaceRebuilt from scratch: consistent indent, one value per line, a space after each colon. This is the only change in default mode.
    ValuesUntouched. Strings keep their exact characters and escapes, numbers keep their value, true/false/null stay as they are.
    Key orderPreserved by default. Choosing Sort keys A–Z reorders keys alphabetically at every level — handy for diffing two API responses.
    Duplicate keysJSON technically allows them and parsers keep the last value. If your input repeats a key inside one object, this tool warns you instead of silently dropping the earlier value.
    MinifyRemoves all optional whitespace, producing the smallest valid one-line form — ideal for embedding in requests, configs and payloads where size matters.

    Reading the error messages

    When JSON will not parse, the status line names the first problem and its line and column, and the guide below covers the usual suspects. A classic is the trailing comma:

    { "name": "Ada", "age": 36, }

    Paste that in and the formatter reports the problem at line 4, column 1 — after the comma it expected another key, but found the closing brace. Other frequent fixes: use double quotes for keys and strings (never single quotes), quote your keys, remove comments (// and /* */ are not valid JSON), and check that every { and [ is closed.

    What to do with your formatted JSON next

    Formatted JSON is usually a waypoint, not the destination. The Send formatted JSON to… bar under the output carries the current result into the next tool for you:

    1. Double-check it — send it to the JSON Validator for a dedicated validity report before you ship it.
    2. Turn it into a table — arrays of objects convert cleanly with JSON to CSV for spreadsheets and imports.
    3. Encode it for transport — Base64 for embedding in headers or tokens, or the URL Encoder/Decoder when JSON has to travel inside a query string.
    4. Keep a reference offline — download the cheat sheet from the tool above: syntax rules, the six value types, common error fixes and indent guidance in one text file.

    Working the other way? Generate a test payload with the Fake Data Generator, or convert a spreadsheet export with CSV to JSON, then chain the result back here to format it.

    Frequently asked questions

    What does a JSON formatter do?

    It takes JSON in any shape — minified onto one line, or messy with inconsistent spacing — and rewrites it with consistent indentation, one value per line, so it is easy to read, compare and debug. This formatter can also do the reverse (minify), sort object keys A–Z, and show the data in a collapsible tree view.

    Should I use 2 spaces, 4 spaces or tabs to indent JSON?

    Two spaces is the most common convention — it is the default in most editors, APIs and tools like JSON.stringify and Prettier. Four spaces reads a little easier in deeply nested data, and tabs let every viewer choose their own visual width. There is no wrong choice; pick what your team or project already uses.

    Why is my JSON invalid?

    The most common causes are trailing commas after the last item, single quotes instead of double quotes, unquoted keys, comments (JSON does not allow them), and missing commas or brackets. This formatter reports the exact line and column of the first problem and explains what it expected to find there.

    Does formatting change my data?

    No. Formatting only changes whitespace between tokens — the values, key order (unless you choose Sort keys A–Z) and number values are preserved exactly. Minifying is equally lossless: it removes the whitespace again. One caveat: keys that look like whole numbers ("2", "10") always follow JavaScript's numeric-first ordering when re-serialized.

    What is the difference between the JSON Formatter and the JSON Validator?

    The formatter's job is to reshape valid JSON — beautify, minify, sort and explore it — and it validates as part of that. The standalone JSON Validator focuses purely on checking: paste JSON and get a detailed validity report. Use whichever matches the task; both pinpoint errors by line and column.

    Is my JSON uploaded or stored?

    No. Parsing and formatting happen entirely in your browser with JavaScript — nothing is uploaded, stored or tracked, so it is safe for API responses and config files. Avoid pasting live secrets into any online tool as a general habit, but here nothing leaves your device.

    Can I send formatted JSON straight to the validator or converters?

    Yes. Use the Send formatted JSON to… bar under the output: it carries the current formatted result in the link to the JSON Validator, JSON to CSV converter, Base64 or URL encoder, so you can validate, convert or encode it without copying and pasting. Very long payloads are copied to your clipboard instead.

    Does this page remember my JSON between visits?

    No. History snapshots, pinned favorites and the recently-used tools list live only in this tab's session memory and disappear when you close or reload the tab. Your JSON itself is never written to storage, uploaded or tracked — close the tab and it is gone.

    Related encoding & conversion tools

    About this tool

    The JSON Formatter is one of 33 free utilities in the Online Utilities Suite at dev.conversiontools.online. It uses a strict JSON parser written for this page, so error messages can name the exact line and column and explain what was expected — and warn about duplicate keys that standard parsers silently overwrite. Every tool in the suite runs entirely in your browser, so results are instant and private even on large payloads.

    Privacy

    This page processes everything locally in your browser: no account, no uploads, and nothing you paste is stored or sent to a server. Files you open are read on your device only. Advertising on this site is served by Google AdSense, which may use cookies to personalize ads; you can opt out of personalized advertising in your Google ad settings.