Back to blog
TutorialsSeptember 15, 2025

How to Beautify JSON in Your Browser (Without Sending It Anywhere)

Three ways to format minified JSON locally — browser tools, DevTools, and command line. Pick the one that fits your situation.

JSONdeveloper toolsJSON formattertutorial

Minified JSON is unreadable. A 5 KB API response on one line is a wall of characters that no human can debug. You need it indented, line-broken, and structured.

Most developers reach for one of three methods to format JSON. Here's when each one wins.

Method 1: Browser-Based JSON Formatter (Fastest)

For any one-off formatting task: open a JSON formatter, paste the minified JSON, click Format. Done in 5 seconds.

Why it wins:

  • No installation required
  • Works on any device
  • Catches syntax errors with line and character position
  • Runs entirely in your browser your JSON never goes anywhere

Example. Paste this:

{"user":{"id":1,"name":"Alice","tags":["admin","editor"]},"timestamp":1640995200,"meta":{"v":"1.0"}}

Get this:

{
  "user": {
    "id": 1,
    "name": "Alice",
    "tags": [
      "admin",
      "editor"
    ]
  },
  "timestamp": 1640995200,
  "meta": {
    "v": "1.0"
  }
}

The hierarchy is now obvious. You can see immediately that tags is an array, id and timestamp are numbers, and the nesting is two levels deep.

Method 2: Browser DevTools

If the JSON is already in a network response in DevTools, you don't need to copy it anywhere:

  1. Open DevTools → Network tab
  2. Click the request
  3. Click the Response tab
  4. Modern browsers (Chrome, Firefox, Edge) format JSON responses automatically when the response Content-Type is application/json

This is the fastest method when you're already debugging an HTTP request and the JSON is the response body.

Limitation: doesn't work for JSON in cookies, localStorage, or pasted from elsewhere. You also can't validate broken JSON this way DevTools just shows what came back.

Method 3: Command Line with jq

For local files or piped output, jq is the standard tool:

# Format a file
cat response.json | jq

# Format a curl response
curl https://api.example.com/users | jq

# Format and extract specific fields
curl https://api.example.com/users | jq '.users[0].name'

jq does much more than format it's a full query language for JSON. But for plain formatting, just piping through jq works.

When to use: scripting, log analysis, anything in a terminal already.

Don't use when: you don't have jq installed and you're in a hurry. Installing it for one task is slower than the browser tool.

Validation vs Formatting

These are related but distinct:

  • Formatting assumes the JSON is valid and reformats it for readability.
  • Validation checks whether the JSON conforms to the JSON specification and reports the location and nature of any error.

A good JSON formatter does both: it validates first, reports any error clearly, and only formats if the input is valid. The JSON validator is the same logic with formatting hidden useful when you specifically want to verify validity without changing the input.

Common JSON Errors a Formatter Catches

ErrorExampleFix
Trailing comma{"a": 1, "b": 2,}Remove the final comma
Unquoted key{name: "Alice"}Wrap key in double quotes
Single quotes{'a': 1}Use double quotes
Comments{"a": 1 // comment}JSON doesn't support comments
Mismatched brackets{"a": [1, 2}Close brackets match opening
Unescaped characters{"a": "line1\nline2"} is fine, but raw newlines in strings are notEscape \n, \t, etc.

If you're seeing "Invalid JSON" with no detail, the JSON formatter gives you the exact line and character of the failure.

What Indentation Should You Use?

The two common conventions:

  • 2 spaces most popular, used by JavaScript ecosystems, smaller file size
  • 4 spaces used by some Python, Go, and older codebases
  • Tabs rare in JSON specifically, more common in source code

The JSON formatter defaults to 2 spaces, which matches what 90% of tools and codebases use.

Privacy: Why Local Processing Matters

JSON often contains sensitive data:

  • API tokens and secrets
  • User PII (names, emails, addresses)
  • Internal IDs and business logic
  • Financial data, healthcare records

Pasting this into a server-side JSON formatter sends all of it to that server. The server might log it, cache it, or keep it for "processing efficiency".

The browser-based formatter processes everything in JavaScript locally. Try it offline the page still works. That's how you know nothing's being uploaded.

Quick Reference

SituationUse this
One-off paste-and-formatBrowser JSON formatter
Already in DevToolsDevTools' built-in JSON view
Local file or piped outputjq
Just check validityJSON validator
Sensitive dataBrowser formatter (client-side only)

For most people, most of the time, the JSON formatter wins on speed and safety. Bookmark it.

Related articles