A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.

Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.

✓ Free to use✓ No sign-up✓ 500+ possibilities
Developer

JSON Formatter

Format, validate and minify JSON

Loading interactive tool…

About this tool

JSON Formatter is a browser-based tool that prettifies, minifies, and validates JSON without sending it to a server. Paste JSON from an API response, config file, or log dump; formatting uses fixed two-space indentation, minification produces a compact string, and parse errors are shown in the result area. Processing uses the browser's native JSON engine, so the input stays in the browser tab.

Why use it

  • Formats valid JSON with consistent two-space indentation.

  • Minifies valid JSON to a compact single-line string.

  • Reports native parser errors when the input is invalid.

  • Runs in the browser using the native JSON engine.

  • Copies the formatted or minified result with one click.

How to use

  1. Paste or type your raw JSON into the input area on the left.
  2. Click 'Format JSON' to validate and prettify with two-space indentation.
  3. If the JSON is invalid, an error banner appears; fix the input and format again.
  4. Click 'Minify' to collapse valid JSON to one compact line.
  5. Use Copy result to copy the formatted or minified output.

When it helps

  • Debugging a REST API response that is returned as a minified single-line string.
  • Validating a hand-edited config.json or package.json before running a build.
  • Preparing a JSON snippet for documentation, a README, or a pull-request description.
  • Inspecting a webhook payload copied from a logging service like Datadog or Sentry.
  • Minifying a large JSON data file before embedding it as an inline script variable.
  • Confirming that a generated JSON export from a database or ETL pipeline is structurally valid.

Examples

Prettify a minified API response

Input
{"user":{"id":1,"name":"Alice","roles":["admin","editor"]}}
Expected result
{
  "user": {
    "id": 1,
    "name": "Alice",
    "roles": [
      "admin",
      "editor"
    ]
  }
}

Detect a trailing-comma error

Input
{"host":"localhost","port":5432,}
Expected result
Error on line 1, col 31: Unexpected token } — trailing comma after last property is not valid JSON.

Minify a readable config for embedding

Input
{
  "debug": false,
  "timeout": 30,
  "retries": 3
}
Expected result
{"debug":false,"timeout":30,"retries":3}

Tips

  • Use Format JSON to validate and prettify the input.
  • If an API returns a JSON string wrapped in extra quotes, remove the outer quotes first when you intend to format an object.
  • Minify before embedding JSON in a script when you need to reduce whitespace.
  • When debugging a JSON parse error, paste the raw string here to inspect the browser parser message.

Frequently Asked Questions

Does the formatter send my JSON to a server?
No. All formatting and validation runs entirely in your browser using the native JavaScript JSON engine. Nothing is uploaded, stored, or transmitted — making it safe for tokens, credentials, and private data.
What is the difference between prettify and minify?
Prettify adds consistent indentation and newlines so the structure is human-readable. Minify strips all unnecessary whitespace to produce the smallest possible string, which reduces payload size for HTTP requests or inline scripts.
Why does the formatter say my JSON is invalid when it looks correct?
Common causes include trailing commas after the last item in an object or array (not allowed in JSON), single-quoted strings instead of double-quoted, or JavaScript-style comments. The error message shows the exact line and column to help you find the issue quickly.
Can I format JSON5 or JSONC (JSON with comments)?
The formatter follows the strict JSON specification. JSON5 and JSONC extensions such as comments and trailing commas are not valid JSON and will trigger a parse error. Remove comments before formatting, or use a dedicated JSON5 parser.
Is there a size limit on the JSON I can paste?
There is no hard limit enforced by the tool. Very large files (tens of MB) may be slow to render because the browser must parse and then syntax-highlight the entire payload, but for typical API responses and config files there is no practical constraint.
Can I use this to compare two JSON objects?
This tool focuses on formatting and validation. For structural comparison, use the JSON Diff tool in the Data category, which shows added, removed, and changed keys side by side.
Does it preserve key order?
Yes. The formatter uses JSON.parse followed by JSON.stringify, which preserves the order of keys as they appear in the original input. It does not sort keys alphabetically unless you explicitly choose a sort option.
Can the tool format a JSON array at the root level?
Yes. The root of a JSON document can be an object, an array, a string, a number, a boolean, or null — all are valid according to the spec and are handled correctly by the formatter.

Explore the category

Glossary

JSON
JavaScript Object Notation — a lightweight, text-based data interchange format using key-value pairs and ordered lists. Defined by RFC 8259 and ECMA-404.
Prettify
The process of adding consistent indentation and line breaks to a JSON string so its hierarchical structure is immediately readable by a human.
Minify
Stripping all non-significant whitespace from a JSON string to produce the smallest possible byte representation, reducing network payload size.
Syntax Error
A character or token in the JSON string that violates the specification — such as a trailing comma, unquoted key, or mismatched bracket — causing parsers to reject the entire document.
Syntax Highlighting
Colouring different token types (keys, strings, numbers, booleans, null) in distinct colours to make the structure of a document easier to read visually.
Indentation
The number of spaces (commonly 2 or 4) added at the beginning of each nested line when prettifying JSON to visually represent the depth of each value.