JSON Formatter

Format, pretty-print, and validate JSON in your browser.

Input data is processed in your browser
Data is never sent to a server

Tool

0 chars

or drag & drop a file

What is JSON Formatter?

JSON Formatter pretty-prints compact single-line JSON into a readable indented format, and can also minify JSON by removing all whitespace. It also validates JSON syntax as you format.

It’s handy when you need to quickly inspect an API response while developing or debugging, or when you want to tidy up config files like package.json or tsconfig.json.

When this comes in handy

  • An API response comes back as one unreadable line: browser DevTools and curl often return responses with no line breaks at all. Paste it in here and the structure becomes instantly readable.
  • You can’t tell which } matches which { in deeply nested JSON: once formatted, each level is indented, making it much easier to visually trace matching brackets.
  • You want to shrink JSON before sending it as a request body or log entry: the “Minify” button does the opposite of formatting, stripping unnecessary line breaks and whitespace to reduce payload size.
  • You want to catch typos in hand-written JSON: missing commas, unclosed quotes, and other syntax errors are surfaced the moment you try to format.

Usage examples

Example 1: Formatting a nested object

Input (minified, single line):

{"user":{"id":1,"name":"Taro","roles":["admin","editor"]},"active":true}

Formatted:

{
  "user": {
    "id": 1,
    "name": "Taro",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "active": true
}

Even when an object contains further nested objects or arrays inside user, each level is indented so it’s clear which value belongs to which key.

Example 2: Formatting an array of objects

The “array of objects” shape common in list-style API responses also becomes much easier to scan once each element is separated out.

Input:

[{"id":1,"price":1200},{"id":2,"price":980}]

Formatted:

[
  {
    "id": 1,
    "price": 1200
  },
  {
    "id": 2,
    "price": 980
  }
]

Example 3: Minifying formatted JSON

To go the other way and compress formatted JSON back to a single line, use the “Minify” button. This is useful when whitespace and line breaks aren’t allowed, such as embedding config data in a URL query parameter.

Input:  multi-line, indented JSON
Output: {"user":{"id":1,"name":"Taro"},"active":true}

What happens on a syntax error

If your input isn’t valid JSON — a missing comma, an unquoted key, and so on — the parser returns information about the error location. Use the line/character position shown in the error message to find and fix the problem, then try again. Common mistakes include:

  • An extra comma left after the last element of an array or object (trailing comma)
  • A key name that isn’t wrapped in double quotes (single quotes or no quotes at all)
  • An unescaped newline or double quote inside a string value

Use Cases

  • Inspecting and formatting API responses
  • Improving readability of config files (package.json / tsconfig.json)
  • Checking data structures during frontend development
  • Debugging during backend development
  • Validating JSON syntax

How to Use

  1. Paste JSON text into the input field.
  2. Click "Format" to pretty-print with indentation.
  3. Click "Minify" to remove all whitespace.
  4. Click "Copy Result" to copy to clipboard.

FAQ

Is this tool free?

Yes, it is completely free.

What happens if I enter invalid JSON?

A parse error message is displayed. Use the error details to correct your input.

Can it handle large JSON files?

It depends on your browser's memory, but typical JSON files are handled without issue.

Is my data sent to a server?

No. All processing happens entirely in your browser (client-side). Nothing is sent to an external server.

Can it format JSON with comments (JSONC)?

The standard JSON parser doesn't allow comments, so input containing comments will produce an error. Remove any comment lines before formatting.

Does it change the order of keys?

No. Both formatting and minifying preserve the original key order from your input. Keys are never reordered alphabetically or otherwise.

Example

Paste minified JSON and it's instantly pretty-printed with indentation.

Input

{"name":"Torinoa Tools","version":"1.0.0","features":["free","no-login","browser-only"]}

Output

{
  "name": "Torinoa Tools",
  "version": "1.0.0",
  "features": [
    "free",
    "no-login",
    "browser-only"
  ]
}