Home / Developer tools / XML beautifier

XML Beautifier

Turn minified or one-line XML into readable, indented code. Paste it from a log, an API response or a file and see the structure at once.

Layout

Beautified XML

When you need an XML beautifier

XML is often sent and stored with all the line breaks removed. You meet it in forms like these:

  • a SOAP request or response copied from a log or a debugging tool,
  • an RSS or Atom feed, or a sitemap, that a server prints on one line,
  • an API response or a message from a queue,
  • an SVG or configuration file that a tool has minified,
  • a value in a database column that holds XML.

The beautifier adds the line breaks and the indentation that these sources remove, so that you can see how the elements are nested and where an attribute or a value sits.

Example

<?xml version="1.0"?><feed><entry id="1"><title>First</title><link href="http://example.com/1"/></entry><entry id="2"><title>Second</title><link href="http://example.com/2"/></entry></feed>

becomes:

<?xml version="1.0"?>
<feed>
  <entry id="1">
    <title>First</title>
    <link href="http://example.com/1"/>
  </entry>
  <entry id="2">
    <title>Second</title>
    <link href="http://example.com/2"/>
  </entry>
</feed>

How to read a long XML document

  1. Beautify it first, so that every element has its own line.
  2. Find the root element and its direct children. They show what the document is made of.
  3. Follow one branch down to the value you need. The indentation shows the path.
  4. Look at the attributes of the elements on that path. A namespace prefix such as soap: tells you which vocabulary an element comes from.

What the beautifier keeps

  • Mixed content (text with elements inside) is copied exactly, so that the spaces in a paragraph do not change.
  • CDATA sections, comments, processing instructions and the DOCTYPE are kept.
  • An element with xml:space="preserve" is not touched.

Beautifier or formatter?

The two names describe the same job. This page is set up for the common case of unreadable XML, and the XML formatter page has the same options and is meant for tidying XML that you write yourself. Both keep the data and change only the layout.

If nothing happens

The XML must be well-formed. If it has an error, the tool lists it with the line and column. XML copied from a log often has an unescaped ampersand or is cut off at the end. The XML validator explains the errors and fixes bare ampersands.

See also the XML minifier for the reverse, the XML formatting guide, the XML to JSON converter and the HTML beautifier.

Frequently asked questions

How do I beautify XML?

Paste the XML. The tool adds line breaks and indentation at once. Copy the result or download it as a file.

Can I beautify a SOAP message or an RSS feed?

Yes. Any well-formed XML works, including SOAP envelopes, RSS and Atom feeds, sitemaps and SVG.

Will beautifying change the text in my elements?

Spaces between elements become indentation. Mixed content and elements with xml:space="preserve" are copied exactly. For simple elements, you can choose whether the spaces around the text are trimmed.

What is the difference between an XML beautifier and a formatter?

There is no real difference. Both change the layout of the document and keep its data.