Skip to content

XML Formatter & Beautifier

Indent messy or single-line XML so its structure is easy to read.

XML input

Tab inserts indentation. Press Escape, then Tab, to move focus out of the editor.

Formatted XML

How to format XML

  1. Paste XML on the left, or open or drop an .xml, .svg or feed file.
  2. The indented XML appears on the right. Pick 2 spaces, 4 spaces or tabs.
  3. Copy the result or Download it as an .xml file.

Pretty print XML safely

XML from APIs, exports and build tools is often written on a single line. The XML formatter puts each element on its own line and indents it by depth, so the hierarchy is obvious at a glance.

Before
<note><to>Tove</to><from>Jani</from><body>Don't forget me!</body></note>
After
<note>
  <to>Tove</to>
  <from>Jani</from>
  <body>Don't forget me!</body>
</note>

Unlike simple search-and-replace formatters, it parses the document first. Text, CDATA sections, comments and entity references are left exactly as written, and elements that mix text with child elements — such as <p>Hello <b>world</b></p> — stay on one line so no spaces are added to the text.

Features

  • Keeps the XML declaration, DOCTYPE, comments and processing instructions.
  • Clear errors with line and column when the XML isn't well-formed.
  • Works with SVG, RSS/Atom, sitemaps, SOAP, Maven and Android layout files.
  • Runs in your browser — files are never uploaded.

Use cases

  • Read a SOAP or REST response that came back as a single line.
  • Clean up an exported sitemap, feed or configuration file before editing it.
  • Make SVG source readable before tweaking paths or attributes by hand.

Related XML tools

To only check the syntax, use the XML validator; to browse a large document, the XML viewer shows it as a collapsible tree. The XML minifier does the opposite of formatting, and XML to JSON converts the data for use in JavaScript. Working with JSON? Try the JSON formatter.

Frequently asked questions

Does the XML formatter change my data?
No. It only adds indentation between elements. Text content, CDATA sections, comments, attribute values and entities stay exactly as written. Elements that mix text and child elements are kept on one line so their text isn't changed.
Why does the formatter report an error?
Your XML must be well-formed to be formatted. The error shows the line and column, for example an unclosed tag or an “&” that should be written as &amp;. Fix it, or check the details in the XML validator.
Can I format SVG, RSS or config files?
Yes. Any XML-based format works: SVG, RSS and Atom feeds, sitemaps, Android layouts, Maven pom.xml, .NET config files and more.
Is the XML declaration kept?
Yes. The <?xml … ?> declaration, DOCTYPE, comments and processing instructions are preserved.