Back to Tools

API Response Formatter

Format, beautify and highlight JSON/XML API responses instantly.

Input Data

Turn a wall of API output into something you can read

When you call an API from a terminal, a log file or a browser network tab, the body often arrives as one long line of minified JSON or XML. The API Response Formatter takes that raw text, works out whether it is JSON or XML, and prints it back with consistent indentation and colored syntax. It is aimed at developers who need to inspect a payload quickly without opening an editor or installing a plugin.

Using the formatter step by step

  1. Paste the raw response into the Input Data box. If you only want to try it, click Sample to load a small login-style JSON response.
  2. Click Process Now.
  3. Read the result in the panel below. A summary row shows the Detected Format (JSON or XML) and the input length in characters.
  4. Use Copy to put the formatted text on your clipboard, or Download to save it as a text file named result.txt.
  5. Click Clear to empty the box before pasting the next response.

How detection and formatting work

The tool first tries to parse your input as JSON. If that succeeds, it re-prints the data with four-space indentation and colors keys, strings, numbers, booleans and null differently. If parsing fails and the text begins with a less-than sign, it treats the input as XML and places each tag on its own line with nested indentation. Anything else produces an error message asking for valid JSON or XML. All of this happens with JavaScript in your browser page.

Where it helps

  • Checking a webhook payload copied from a provider dashboard before writing a handler for it.
  • Reading a SOAP-style or legacy XML reply that arrives without line breaks.
  • Making a response readable before pasting it into a bug report or a pull request description.
  • Comparing the shape of a live response with the example in an API's documentation.

Things to keep in mind

JSON must be strictly valid: trailing commas, single-quoted strings and unquoted keys will fail the parse, and the tool will then report an error unless the text starts with an angle bracket. The XML indenter is a simple line-based approach, so it suits ordinary documents but is not a validator, and it will not repair unbalanced tags or reorder attributes. Comments, CDATA sections and mixed content may not indent the way a full XML editor would. If you paste a response that includes HTTP headers above the body, remove them first, since only the body should be formatted.

Formatting changes only whitespace and colors in what you see. Copy and Download use the plain text of the result, so you get clean indented output without any styling markup.

Related Articles


Related Tools






Frequently Asked Questions

Does the tool send my API response to a server?
The formatting logic is JavaScript that runs in your browser page, and the input is parsed and printed locally by that script. Nothing on the tool page submits a form. Even so, avoid pasting live secrets such as production tokens if you are working on a shared computer.
Why do I get an 'Invalid JSON or XML format' error?
The text is neither strictly valid JSON nor something starting with a tag. Common causes are trailing commas, single quotes around strings, unquoted keys, or HTTP headers pasted above the body. Remove those, check brackets and quotes, and click Process Now again.
What indentation does the JSON output use?
Valid JSON is re-printed with four spaces per level, and each nested object or array starts on a new line. The Copy and Download buttons give you that same indented text without the color styling.
Can it format XML with attributes and namespaces?
Yes for ordinary documents. Each element goes on its own line and children are indented, with attributes kept inside the tag. It is a lightweight indenter, not a schema validator, so unusual constructs like CDATA or mixed text may not line up perfectly.
What does the Download button save?
It saves the formatted result as a plain text file called result.txt. The file contains the visible text of the output panel, so it is readable in any editor. Rename it to .json or .xml yourself if you need a specific extension.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.