The Util Box

JSON Formatter & Validator

Free online json formatter & validator for developers. Format, validate, and beautify JSON. Fast and private.

Formatted JSON
Paste JSON above

Embed this tool

Copy and paste the code below into your website to embed this tool for free. An attribution link to The Util Box is required.

<iframe src="https://www.theutilbox.org/embed/json-formatter" width="600" height="500" frameborder="0" style="border: none; max-width: 100%;" title="Free JSON Formatter & Validator tool from The Util Box"></iframe>
<!-- Free tool by The Util Box — https://www.theutilbox.org/tools/json-formatter -->
<a href="https://www.theutilbox.org/tools/json-formatter">JSON Formatter & Validator by The Util Box</a>

JSON Formatter — Pretty-Print and Validate JSON Instantly

This JSON formatter re-indents JSON into standard two-space formatting as you paste or type, and immediately tells you what is wrong if the syntax is invalid. The result appears below the input, so you can see the pretty version and the error without switching tabs. Nothing is uploaded — parsing runs against the browser's own JSON.parse, so this works with confidential API responses and offline.

Unformatted JSON is the default output of almost every API, log pipeline and database export. It is technically valid and functionally identical, but it is close to unreadable for a human: a single minified object can be 4,000 characters on one line with no visual indication of nesting. Running it through a JSON beautifier turns that into an indented structure where the shape of the data is obvious.

What This Formatter Does — and What It Deliberately Does Not

Knowing the exact behaviour matters more than knowing the feature list, because most surprises with JSON tools come from assumptions about what "format" implies. This one is deliberately narrow:

  • Two-space indentation, always. Output uses a fixed two-space indent. There is no indent-width selector, because changing it changes bytes and therefore changes nothing about validity.
  • Strict JSON only. Comments, trailing commas, single quotes and unquoted keys are all rejected. That is correct behaviour for JSON, but if your file came from a JSONC, HJSON or YAML file, it will not parse — and the error message will say so.
  • Key order is preserved exactly as written. Keys are not sorted and not reordered. The order you paste is the order you get back.
  • Values are never altered. Numbers, strings, booleans and null survive untouched. A large integer beyond JavaScript's safe range loses precision in the browser, not in the formatter.
  • No round-trip through a data model. The tool parses to a native value and re-serialises, so purely structural whitespace is the only thing that changes.

Reading the Error Messages

When the input will not parse, the result panel turns red and shows the native JavaScript engine message. These are terse but precise, and they follow a consistent pattern that makes them easy to act on:

"Unexpected token } in JSON"

Almost always a trailing comma before a closing brace or bracket, or an extra comma separating the last two members. Some languages and editors emit this while "helping" you.

"Expected ',' or '}'"

A missing comma between members, or a value that is not valid JSON — an unquoted string, a bare word, a JavaScript undefined, or a function reference.

"Unexpected end of JSON input"

The paste was truncated. This is the classic symptom of copying from a terminal that clipped the output, or from a log viewer that paginated it. Re-copy with a larger buffer.

"Unexpected non-whitespace character"

A stray < at the start usually means an HTML error page was copied instead of JSON. Check the response body before the headers.

Because the error surfaces next to the input rather than in a distant log, the fastest workflow is to fix and retype in place — the result panel re-validates on every keystroke.

Practical Uses

  • Debugging an API response — pretty-print a payload to find the field you nested one level too deep.
  • Reviewing a webhook body — read what a third party actually sent before writing a parser against it.
  • Diffing configuration — format two files identically so a text diff shows only the value changes, not the whitespace.
  • Writing test fixtures — produce a readable, correctly-indented fixture to paste into a unit test.
  • Inspecting localStorage and cookies — reveal the JSON a front-end app stored without a dev-tools detour.

The Rest of the JSON Toolkit

Formatting is one step in a longer chain. Depending on whether you are moving data in or out, these are the tools you usually reach for next — all of them local, all of them free:

  • JSON Minifier — the exact inverse, stripping all optional whitespace before you send a payload.
  • JSON Diff — compare two objects structurally and see only the paths that differ.
  • JSON to YAML and YAML to JSON — move between formats for config files and Kubernetes manifests.
  • JSON to XML — for SOAP-based and legacy enterprise endpoints.
  • JSON Path Tester — pull a single value out of a large document without writing a parser.
  • JSON Schema Validator — check a document against its schema, which catches the type errors a syntax formatter cannot.
  • JSON Escape / Unescape — handle a JSON payload that has been embedded inside a JSON string.