Phrasit

Search Phrasit

Search every tool, guide, and citation page.

FREE / JSON / VALIDATOR

JSON formatter

Pretty-print, minify, and validate JSON with precise parse feedback, type detection, and a lightweight expandable tree view.

Type: object
name: "Phrasit"
0: "json"
1: "regex"
live: true

About the JSON formatter

The JSON formatter takes a single block of JSON and does three things at once: it validates it, it pretty-prints it with consistent indentation, and it builds a collapsible tree so you can walk the structure visually. JSON copied out of a log line, a network tab, or a database column usually arrives as one unbroken string, and that is exactly where a missing comma or an unquoted key hides. Reformatting it into indented lines is the fastest way to find the break.

Reach for it when you need to read or sanity-check JSON rather than transport it: inspecting an API response, diffing two payloads, or shrinking a config back to one line before pasting it into an environment variable. Everything runs in your browser, so nothing you paste leaves the page.

How to use it

  1. Paste or type your JSON into the input panel on the left.
  2. Read the badge at the top: it shows the detected type (object, array, or scalar) when valid, or 'Invalid JSON' with the exact line and column when not.
  3. Choose 2 or 4 spaces of indentation, then click Pretty-print to rewrite the input in that style.
  4. Click Minify to strip every space and newline back into the most compact single-line form.
  5. Use the tree view on the right, and the Expand/Collapse toggle, to drill into nested objects and arrays without scrolling raw text.
  6. Click Copy to put the formatted (or minified) result on your clipboard.

Examples

Find the exact position of a syntax error

Paste {"name":"Ada","roles":["admin",]} and the badge turns red with the parser message plus a line and column number. The trailing comma after "admin" is illegal in JSON, so you delete it, the badge flips back to 'Type: object', and the tree view appears.

Pretty-print a one-line API response

Drop in a compact response like {"id":42,"items":[{"sku":"A1"},{"sku":"B2"}]}. Pick 2 spaces, click Pretty-print, and it expands to indented lines with each item on its own row, so a nested array two levels deep becomes obvious at a glance.

Minify config for an env var

A hand-edited settings object spread over twenty indented lines becomes one line after Minify, with all whitespace removed. That single-line form is what you want when a value has to live on one line, such as a JSON string inside a .env file or a CI variable.

Frequently asked questions

Why does it reject JSON that works in my JavaScript file?
JSON is stricter than JavaScript object syntax. Keys must be double-quoted, strings cannot use single quotes, trailing commas are not allowed, and comments are forbidden. The formatter parses by the JSON specification, so anything JavaScript would tolerate but JSON does not gets flagged.
What does the type badge mean?
It reports the top-level value of your JSON: an object (a {} map), an array (a [] list), or a scalar (a bare string, number, boolean, or null). It is a quick check that the document's root is the shape you expected before you read further.
Does formatting change my data?
No. Pretty-print and minify only change whitespace. Keys, values, numbers, and ordering are preserved exactly as the JSON parser read them, so the document is semantically identical before and after.
Is there a size limit?
There is no fixed cap, but everything runs in the browser on the main thread, so a multi-megabyte file can feel slow as the tree re-renders. For very large documents, collapse the tree and work from the formatted text panel.

Good to know

Pretty-printing and minifying are two directions of the same operation. You indent JSON to read or review it, and you minify it to transport it, since whitespace is wasted bytes over the wire and inside config values.

Two limits are worth knowing. JSON has no native comment syntax, so a file with // or /* */ notes will not parse here; strip them or switch to JSON5 or YAML. And JSON numbers are IEEE 754 doubles, so integers above 2^53 can lose precision once parsed, which is why 64-bit IDs are safest kept as strings. For schema validation, key sorting, or JSONPath queries you will need a dedicated validator; this tool focuses on formatting and visual inspection.

Related tools