API Response Formatter
Beautify JSON & XML responses for readability and sharing
API Response Formatter
Beautify JSON & XML responses for readability and sharing
Features
- Auto-detect content type from the input string: JSON, XML, HTML, YAML, plain text, or Base64-encoded payloads — formats appropriately per type rather than blanket pretty-printing
- JSON: pretty-print with configurable indent (2/4/tab), key sort, JSON-Lines support (one JSON object per line), and lazy-tree expansion for million-key documents
- XML/HTML: indent nodes, normalize whitespace between tags, preserve CDATA sections, optional attribute alphabetization for diff-friendly output
- Headers + body split: paste a full raw HTTP response (status line + headers + body) and the formatter splits them, applies header parsing, and indents the body
- Status-code highlighting: 2xx green, 3xx blue, 4xx orange, 5xx red, with hover-tooltips explaining each status (200 OK, 401 Unauthorized, 503 Service Unavailable, etc.)
- Diff mode: paste a previous response in the left pane and the current one in the right; output highlights changed/added/removed fields without considering whitespace differences
- Copy formatted output to clipboard, or download as a .txt/.json/.xml file with appropriate extension based on the detected content type
- Pure client-side: parsing and formatting run in your browser; no upload happens, works offline once cached
How to use
- Paste your API response into the input. Either just the body, or the full raw response (status line + headers + body) — the tool auto-detects.
- The output appears immediately, formatted according to detected content type. The detected type is shown as a label.
- Adjust formatting options if needed: indent size, key sorting, attribute alphabetization, etc.
- For diff mode, paste the previous response in the left pane; differences highlight in the right pane.
- Use Copy or Download to save the formatted output for sharing in a ticket or test fixture.
- For binary or base64-encoded responses, the tool decodes and reveals the underlying content if it's a known format (JSON, image, plain text, etc.).
Tips & Best Practices
- When debugging API contracts, paste both the expected response (from your spec) and the actual response into the diff mode to see exactly which fields drifted.
- For status code investigation, the hover-tooltips reference the RFC sections — handy for understanding rare 429 vs 503 vs 504 distinctions.
- For Base64-encoded JWT payloads, paste just the base64 segment; the tool decodes and pretty-prints. For full JWT inspection, use the JWT Decoder tool which adds signature verification.
- When comparing legacy XML responses, enable attribute alphabetization to make diffs stable across releases.
- For very large JSON responses, run JSON Minify first to confirm structural validity, then re-format here for readability.
FAQ
What content types are auto-detected?
JSON (starts with { or [), JSON-Lines (one object per line), XML/HTML (starts with < or <?xml), YAML (sniffs for key: value patterns), Base64 (only printable Base64 alphabet), and plain text as fallback. The detection runs on the input string; for ambiguous cases, you can override with the manual type selector.
How does header parsing work?
If the input starts with a status line (HTTP/1.1 200 OK), the tool splits on the first blank line into headers and body. Each header is parsed into name + value pairs; the body is formatted per its detected content type. If no status line is present, the entire input is treated as a body.
Will the formatter modify my data?
Only whitespace and ordering. JSON.stringify is lossless for the spec's primitive types; XML re-emitting preserves text content and structure; YAML round-trips don't lose data but may change quote style and flow vs block. If exact byte preservation matters, use a diff tool instead of a formatter.
Why does my JSON show as plain text?
The auto-detect requires the input to start with { or [ (possibly after whitespace). If your input begins with a Byte Order Mark, a UTF-16 marker, or any non-JSON prefix, detection fails. Strip the prefix or override the type with the manual selector.
How does the diff mode handle whitespace?
Diff is structural for JSON/XML/YAML — it compares parsed trees, so reformatting alone doesn't produce false positives. For plain text, diff is line-based (same as `diff -u`). The mode auto-picks structural diff when both inputs detect as the same content type.
Can I view binary responses?
Yes, if they're Base64-encoded as a string. Paste the Base64, the tool detects it, decodes it, and shows the underlying bytes. For known content types (PNG/JPEG header bytes, ZIP signatures), it identifies the format. Truly binary inputs as raw bytes can't be pasted as text — use a hex viewer instead.
Is anything sent to a server?
No. Parsing JSON/XML/YAML, content-type detection, and Base64 decoding all run in your browser. No upload, no logging, works offline once cached.
How large a response can it handle?
Up to ~50MB for JSON and XML, ~10MB for YAML (slower parser). Larger payloads pause the UI during parse; for streaming responses, format chunks separately. Use jq/yq from the command line for truly large data sets.