XML Formatter
Format XML online. Paste XML that has been squeezed onto one line or badly indented and the tool re-indents it by tag nesting level as you type, ideal for tidying API responses and configuration files.
FreeOnline Tool
Loading…
How to Use
- Paste the XML you want to format into the input box
- The "Formatted result" area below shows the XML re-indented with two spaces per level in real time
- If the XML is malformed, a specific error message is shown instead
- Click "Load sample data" to see how a deeply nested XML document is laid out
Features
- Detects opening, closing and self-closing tags and indents them by nesting depth using two spaces per level
- Keeps the XML declaration such as <?xml version="1.0"?> on the first line of the result
- When a tag contains only text, the tag and its text stay on the same line to avoid splitting the document more than necessary
- Formats as you type, with no button to press
Use Cases
Reading single-line XML API responses
Copy the compressed one-line XML returned by a SOAP service or a legacy system and format it into readable lines for troubleshooting.
Tidying configuration files
Reformat hand-written or generated XML configuration into a consistent indentation style for easier version control and review.
Debugging dynamically built XML
XML assembled by code usually comes out as one long line, and formatting it makes structural mistakes much easier to spot.
Preparing XML examples for documentation
Format XML samples into neat, consistently indented blocks when writing technical documentation.
FAQ
Does formatting change my tags or attributes?
No. Only line breaks and indentation whitespace are adjusted. Tag names, attribute values and text content stay exactly as they were.
Why does it say the XML cannot be recognized?
Either the input is empty or the tag structure cannot be split correctly, for example because a tag is unclosed or contains invalid characters. Check the XML and try again.
Does it handle XML with namespaces?
Yes. Tags with a namespace prefix such as <ns:item> are treated as ordinary tag names and indented normally.
Is my data uploaded to a server?
No. Formatting runs entirely in your browser and nothing is uploaded.