Boneyard Tools

XML Formatter and Beautifier

Paste XML to pretty-print or minify it instantly. Each tag is indented by nesting level, attributes and the <?xml?> declaration are preserved, and nothing leaves your browser.

How to format XML

  1. Paste your XML into the editor.
  2. Choose Format to indent it or Minify to strip whitespace, and pick an indent size.
  3. Copy the result or download it as a .xml file.

Examples

Beautify a one-line document

<note id="7"><to>You</to><body>Hi there</body></note>
<note id="7">
  <to>You</to>
  <body>Hi there</body>
</note>

Frequently asked questions

Is my XML sent to a server?

No. Formatting and minifying run entirely in your browser, so your XML never leaves your device.

How does the formatter decide indentation?

It scans the tags: every open tag adds one level of indent, each closing tag removes one, and self-closing tags, text and comments stay at the current level.

Does it keep the <?xml?> declaration and attributes?

Yes. The declaration is placed on its own line and attribute strings are preserved exactly as you wrote them, including quotes and spacing.

What does Minify do?

Minify removes the whitespace between tags to produce a single compact line, which is useful for shrinking payloads or storing XML in one field.

What if my XML is malformed?

If a tag is never closed or a tag is missing its closing angle bracket, you get an error message instead of broken output, so you can fix the source.

Can I change the indent size?

Yes. Pick two spaces, four spaces or tabs. The same indent string is applied at every nesting level.

Learn more

Related tools