UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

JSON Formatter

Format, validate and minify JSON

About JSON Formatter

JSON Formatter is a browser-based tool that instantly prettifies, minifies, and validates JSON without sending anything to a server. Paste raw JSON from an API response, a config file, or a log dump and the formatter adds proper indentation, colorizes keys, strings, numbers, booleans, and null values, and flags syntax errors with the exact line and character position. Toggle between a readable 2-space or 4-space indented view and a compact single-line minified form. Developers use it when reading third-party API payloads, debugging webhook bodies, preparing configuration snippets for documentation, or confirming that a hand-edited JSON file is valid before committing. Because all processing happens in your browser using the native JSON engine, no data ever leaves your machine — critical when working with tokens, credentials, or user-identifiable content.

Why use JSON Formatter

Live Syntax Error Detection

The formatter pinpoints the exact line and character where your JSON breaks — a missing comma, an unquoted key, or a trailing bracket — so you fix the real problem in seconds instead of scanning hundreds of lines manually.

Instant Prettify and Minify Toggle

Switch between human-readable indented output and a stripped single-line payload with one click. This is essential when you need to read an API response locally but must send a compact body in a production request.

Colour-Coded Syntax Highlighting

Keys, string values, numbers, booleans, and null values each render in distinct colours, making deeply nested structures readable at a glance without a full IDE or browser DevTools open.

Zero Data Transmission

All parsing runs inside your browser's native JSON engine. Credentials, auth tokens, private API responses, and PII never leave your device — unlike cloud-based formatters that log or cache submitted payloads.

Handles Large and Complex Payloads

The tool parses deeply nested arrays, mixed-type objects, and Unicode strings without truncating output. Useful for large GraphQL responses or bulk export files that would lag in a basic text editor.

One-Click Clipboard Copy

A dedicated copy button captures the entire formatted or minified output instantly, including accurate indentation, so you can paste clean JSON directly into a code editor, Slack message, or ticket without extra steps.

How to use JSON Formatter

  1. Paste or type your raw JSON into the input area on the left.
  2. Click 'Format' (or press Ctrl+Enter) to prettify with 2-space indentation and syntax highlighting.
  3. If the JSON is invalid, an error banner appears showing the exact line and column of the problem — fix it and reformat.
  4. Toggle 'Minify' to collapse the output to a single compact line, ideal for embedding in config files or HTTP requests.
  5. Use the copy button to copy the formatted or minified output to your clipboard in one click.
  6. Optionally switch indent size between 2 and 4 spaces using the indent selector before formatting.

When to use JSON Formatter

  • 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"]}}

Output: { "user": { "id": 1, "name": "Alice", "roles": [ "admin", "editor" ] } }

Detect a trailing-comma error

Input: {"host":"localhost","port":5432,}

Output: 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 }

Output: {"debug":false,"timeout":30,"retries":3}

Tips

  • Press Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) to format without reaching for the mouse.
  • If an API returns a JSON string wrapped in extra quotes, remove the outer quotes first — otherwise the parser sees a plain string, not an object.
  • Use 4-space indent when copying JSON into Python docstrings or Markdown code fences; the extra width makes nesting levels clearer in monospace rendering.
  • Minify before base64-encoding a JSON payload to reduce the encoded string length significantly.
  • When debugging a JSON parse error in Node.js, paste the raw string here first — the browser engine gives a clearer error message than many server-side libraries.

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.