Input

Output

What is XML Formatter?

Got a one-line SOAP response or a config file somebody saved without line breaks? Paste it here and the XML comes back indented with each element on its own line, which makes it readable again. The output updates as you type.

The formatter only changes indentation between elements. The XML declaration and DOCTYPE are copied as written, comments, processing instructions and CDATA sections stay, and elements marked xml:space="preserve" or holding mixed content (text next to child elements, like <p>Hi <b>Ava</b></p>) are left on one line exactly as they were, so no text changes. The one cleanup it does: a text-only element whose value was wrapped onto its own indented line is pulled back onto one line.

Everything runs in your browser; the XML is not uploaded. Parsing uses the browser's built-in XML parser, so if your document is not well-formed under the W3C XML specification you get its error message instead of output. For a quick second opinion you can also run the result through another online XML formatter.

How to Use the XML Formatter

Follow these steps to format and beautify your XML. Each step uses the actual buttons and panels on this page.

1

Paste, Upload, or Load Sample

Paste minified XML into the left Input panel, or click Upload to load a .xml file. Click Sample to see example telecomm XML. Example minified input:

<subscribers><subscriber><subscriberId>SUB-1001</subscriberId><plan>Unlimited 5G</plan><dataUsage>45.2</dataUsage></subscriber></subscribers>

If the XML is not well-formed, the parser's error message appears above the output panel and nothing is formatted.

2

View Formatted Output

The right Output panel shows the formatted XML. Pick 2 spaces, 4 spaces or Tabs from the indentation menu next to the input buttons. Formatting checks well-formedness only; it does not validate against an XSD or DTD.

3

Copy, Download, or Minify

Click Copy or Download to grab the result. Minify switches the output to a single line with the indentation removed; changing the indentation menu switches back to formatted output. Use Clear to start fresh.

When You'd Actually Use This

API Development

Format XML responses from SOAP services or REST APIs that return XML, so you can see the structure and spot the element that is missing. Pairs well with browser dev tools when the network tab shows one long line.

Config File Review

Reviewing XML configuration files? Format them first to see the structure clearly. Makes it easier to spot errors, understand settings, or compare different configurations.

Learning XML

New to XML? Formatting helps you understand the syntax. See how elements nest, how attributes work, and how data structures are organized. Much easier than reading minified code.

Debugging

Formatting makes nesting visible, which helps you see where an element ended up in the wrong parent. If the document is broken, the parser's error message tells you the line and column to look at.

Common Questions

Is my XML uploaded?

No. Formatting happens in your browser with JavaScript; the XML never leaves your computer.

What does the formatter change?

Only the whitespace used for indentation between elements, plus the trimming of a value that was wrapped onto its own line. Names, attributes, text, comments, CDATA, processing instructions, the XML declaration and the DOCTYPE are kept. Entity references such as &#233; come out as the character they stand for, which means the same thing to any XML parser.

Can I format invalid XML?

No. If the XML is not well-formed, you get the parser's error message instead of output, because guessing at broken markup can change your data. Fix the reported line, or try the XML Fixer, then format again.

What indentation does it use?

Two spaces by default. Switch to four spaces or tabs with the indentation menu next to the input buttons.

Why is one element still on a single line?

It either has mixed content (text and child elements together) or xml:space="preserve". Adding line breaks there would change the text, so it is left as it was. The white space section of the XML spec explains why that whitespace counts.

How big can my file be?

Up to 5 MB. Larger files are refused to keep the page responsive; xmllint --format from libxml2 handles big files on the command line.

Other XML Tools You Might Need

Formatting is just one XML task. Here are other tools that work well together: