JSON Formatter & Validator — Beautify, Minify & Escape Online

JSON Formatter Tool

JSON

About the JSON Formatter Tool

Overview

A network response logged as one unbroken line of JSON is nearly impossible to scan by eye, and copy-pasting it into a code editor just to read it is a detour you shouldn't need. This tool turns that single line into an indented, readable tree instantly, and just as easily collapses a formatted JSON document back down to a compact one-liner for sending over the wire.

Switching to a full IDE just to eyeball one payload is overkill when you only need the shape of the data for a minute. Because everything runs client-side, you get that instant readability without ever routing the response through a third-party server first.

How to Use

  1. 1Drop your raw JSON — minified, multi-line, whatever shape it's in — into the text area.
  2. 2Choose Format under Mode to pretty-print it, or Minify to collapse it to a single line.
  3. 3If you're formatting, set the Indentation to 2 or 4 spaces to match your project's style.
  4. 4Click Format to run the conversion and see the result on the right.
  5. 5Use the copy button to grab the output straight to your clipboard.

Tip: if the conversion fails, look for the usual suspects — a stray trailing comma, single-quoted strings, or an accidental comment. The error message points to roughly where the parser gave up.

Specifications & Glossary

  • JSON (JavaScript Object Notation): The de facto data interchange format on the web, defined by the RFC 8259 / ECMA-404 standards. It is the default body format for REST APIs and is also used for config files like package.json and tsconfig.json.
  • Format mode: Adds indentation and line breaks to make JSON easy to read. Nested objects and arrays are displayed in a hierarchical structure.
  • Minify mode: Removes all line breaks and spaces to compress JSON into a single line. Useful for reducing network transfer size or when using JSON as an HTTP request body.
  • Indentation: Sets the number of spaces to use in format mode (e.g., 2 spaces, 4 spaces). Select according to your team's coding style.
  • Validation: Invalid input surfaces an error message instead of silently failing. Two of the most common gotchas: unlike JavaScript object literals, JSON keys must use double quotes (not single quotes), and a trailing comma after the last item or property is a syntax error, not a style choice.
  • About RFC 8259: This is the internet standard that defines JSON's grammar. Only six value types exist — object, array, string, number, boolean, and null — with no native date type, functions, or comments. It resembles a JavaScript object literal, but keys must always be double-quoted and there is no way to represent `undefined`.
  • JSONC and JSON5 aren't plain JSON: Files like tsconfig.json use a relaxed superset called JSONC that permits comments and trailing commas, but that syntax isn't valid per the JSON spec itself. Since this tool parses strict RFC 8259 JSON, pasting a JSONC file with comments intact will raise an error.

Use Cases

  • Formatting and debugging API responses for readability.
  • Reviewing and editing configuration files such as package.json and tsconfig.json.
  • Minifying JSON before sending it over the wire to shave off payload size.
  • Tracking down an "Unexpected token" parse error caused by a trailing comma or a single-quoted key copied from JavaScript — paste the snippet here to spot exactly where it breaks.
  • Formatting a one-line nested response like "user":"id":1,"roles":["admin","editor"] to immediately see what's inside the nested `roles` array.
  • Pasting one line at a time from a JSON Lines (NDJSON) server log to inspect the field values on the entry where an error occurred.

FAQ

Is my pasted JSON data sent to a server?
No. All formatting and minifying happens client-side in your browser, so nothing you paste — including responses with API keys or personal data — ever leaves your machine.
Can this format JSONC (JSON with comments)?
Not directly — the parser follows strict JSON (RFC 8259), so comments and trailing commas from JSONC-style files (like tsconfig.json) will throw a syntax error. Strip the comments first, or convert the file to plain JSON before pasting.
Why do I get an "Unexpected token" error?
Usually one of three culprits: single-quoted keys or strings (JSON requires double quotes), a trailing comma after the last item, or a bare `undefined` value. Check the character position the error message points to.
Why does a very large number sometimes come out changed?
Because JSON numbers are parsed as IEEE 754 double-precision floats, integers larger than 2^53 — a common issue with Snowflake IDs or bigint database columns — can lose precision. Check whether the API is meant to represent that field as a string instead.
Can I format just part of a nested array or object?
Not currently — formatting and minifying always apply to the whole document. To work on a single nested object or array in isolation, extract that fragment and paste it in on its own.
Does this handle non-ASCII text like Japanese correctly?
Yes. Multi-byte strings — Japanese text, emoji, anything in UTF-8 — format correctly whether they're written as raw characters or escaped \uXXXX sequences. Switch to Minify to check how the output represents them.