PTBox

Online JSON Formatter & Validator

Online JSON formatter — beautify (indent), minify and validate JSON in your browser. Errors are highlighted with the exact location. One click expands nested JSON: middleware and SAP-style APIs often encode the real payload as an escaped string inside a field, and this recursively restores it to a proper structure while leaving order ids, dates and other string values untouched. Everything runs locally; data is never uploaded.

Usage

JSON is a lightweight data interchange format widely used for APIs and config files. This tool parses your input and re-emits it:

  • Format: pretty-print with 2/4-space or tab indentation;
  • Minify: strip all whitespace for the most compact representation;
  • Validate: just check the JSON is well-formed.

Expanding nested JSON

Middleware, SAP and gateway APIs often bury the real payload inside an escaped string field, e.g. {"OUTPUT":"{\"msgType\":\"S\",...}"}. Such a response is perfectly valid JSON, so formatting it just yields a single key whose value is one unreadable escaped line.

Tick Expand nested JSON and the tool recursively replaces those fields with the structure they encode, unwrapping several levels at once. When such a field is detected, the page prompts you about it.

To avoid corrupting data, only strings that begin with { or [ and parse completely are expanded — order ids, dates and status codes such as "3" or "20260814" stay strings and are never coerced into numbers.

Escaped fragments copied out of a log (e.g. {\"a\":1}, without the surrounding quotes) can also be pasted directly.

All parsing happens locally via JSON.parse. Your input is never uploaded.

Use cases

Debugging API responses

Pretty-print compact JSON returned by the backend to inspect fields easily.

Maintaining config files

Check package.json, tsconfig.json and similar configs are valid JSON to avoid tooling errors.

Documentation & examples

Minify example JSON to a single line for embedding in Markdown or code comments.

Pinpointing parse errors

Highlight exact line and column on failure to quickly find stray commas or single quotes.

FAQ

Is my data uploaded?

All parsing is done locally in your browser via JSON.parse. Your input is never sent to any server.

How large a JSON can it handle?

Limited by browser memory. Up to ~10 MB is usually smooth; larger inputs may stall.

Does it support JSONC (JSON with comments)?

Standard JSON forbids comments. Strip // and /* */ comments manually before pasting.

Why does it say Unexpected token?

Usually a trailing comma, single quotes, an unquoted key, or a smart-quote pasted from rich text. The tool shows the exact location.

What's the difference between format and minify?

Format adds indentation for readability; minify strips all whitespace for transport. Semantic content is identical.

My API response wraps its payload in an escaped string — formatting still gives one long line. What now?

Responses like {"OUTPUT":"{\"msgType\":\"S\",...}"} are valid JSON; the real data just happens to be encoded as a string. Tick "Expand nested JSON" to recursively restore the real structure, however many levels deep it goes. The page prompts you whenever such a field is detected.

Will expanding turn my order ids and dates into numbers?

No. Only strings starting with { or [ that parse completely are expanded. Values like "3", "20260814" and "401" stay strings — types are never rewritten.

Can I paste an escaped fragment copied from a log?

Yes. A fragment such as {\"a\":1} without surrounding quotes is unescaped and parsed automatically — no need to hand-replace \" with ".

Related tools

Comments

0 / 1000