XML Formatter and Validator

Paste XML to check it, then format it with clean indentation or minify it. The tool tells you right away if the XML is well formed, and points at the exact line and column when it is not. Everything runs in your browser, so your data stays on your device.

Paste or type XML to check it
Indent
Result

What is XML formatting?

XML is a plain text format that stores data inside nested tags, used in config files, RSS feeds, SVG images, sitemaps, and many APIs. When it is packed onto one line it is very hard to read. Formatting rewrites the XML with each element on its own line and nested elements indented, so the tree structure is clear. This tool formats your XML, checks that it is well formed, and can minify it back down when you need the smallest version.

Why use our XML formatter

  • ·Free. No signup, no paywall, no limits.
  • ·Runs in your browser. Your XML is never uploaded, so it is safe for private data.
  • ·Live checking. See if your XML is well formed as you type, with the exact line and column of any error.
  • ·Format or minify. Pretty print for reading, or shrink it down, in the same place.
  • ·Syntax highlighting. The editor colours tags, attributes, and values so it is easy to scan.

XML formatter options

Format

Rewrites your XML with each element on its own line and nested elements indented. Turns a wall of tags into a clear tree you can read.

Before<a><b>x</b><c>y</c></a>After<a> <b>x</b> <c>y</c> </a>

Minify

Removes the spaces and line breaks between tags to give you the smallest XML on as few lines as possible. Good for saving space or sending over the wire.

Before<a> <b>x</b> </a>After<a><b>x</b></a>

Validate

Checks that your XML is well formed as you type: every tag closed, properly nested, one root element. Errors show the exact line and column.

Before<a><b>x</c>AfterError on line 1: tag mismatch b and c

Indent

Choose 2 or 4 spaces for each level of nesting, so the formatted XML matches the style used in the rest of your project.

Before2 spaces or 4 spacesAfterYour choice per level

Common XML errors and how to fix them

The checker tests whether your XML is well formed, which means it follows XML's basic rules. These mistakes cause most errors:

ProblemExampleFix
An ampersand in text<name>Tom & Jerry</name>Write it as &amp;
A less-than sign in text<if>a < b</if>Write it as &lt;, or wrap the text in a CDATA block
Tags that do not match in case<Item>...</item>XML is case sensitive, so both tags must match exactly
Tags closed in the wrong order<b><i>text</b></i>Close the inner tag first: </i></b>
More than one root element<a/><b/>Wrap everything in a single parent element
An attribute value without quotes<item id=5>Quote every value: id="5"

Well formed vs valid XML

Well formed means the XML follows the syntax rules above, so any XML reader can open it. Valid goes a step further: the document also matches a schema (an XSD or DTD) that says which elements and attributes are allowed and in what order.

This tool checks that XML is well formed. It does not check it against a schema, so a sitemap, RSS feed, or config file can pass here and still be rejected by a program that expects particular elements. For that, use the validator that comes with the program or the schema's own tools.

When to format XML

XML turns up in a lot of places, and it is often packed onto one line. Here are the most common reasons people format and check it:

  • ·Reading an API response. Paste a minified XML response to see its structure and find a field.
  • ·Fixing a broken feed or config. Find the unclosed tag that is stopping an RSS feed or config file from loading.
  • ·Reading SVG source. Format the XML inside an SVG so you can find and edit a shape by hand.
  • ·Preparing a payload. Minify a formatted document down before sending it in a request.

Frequently asked questions

What is an XML formatter?
An XML formatter takes XML that is on one line or has messy spacing and rewrites it with each element on its own line and nested elements indented, so the structure is easy to read. It does not change the data, only the layout. This tool also checks that your XML is well formed and can minify it back down.
How do I format XML?
Paste your XML into the input box. The tool checks it as you type and shows a green message when it is well formed. Pick your indentation, then click Format to see the clean version below. Click the copy button to copy it, or download it as a .xml file.
How do I know if my XML is valid?
The status bar under the input box updates live. If the XML is well formed, it shows a green check. If something is wrong, it shows the line and column of the problem along with a short message, so you can jump straight to the spot that needs fixing.
What does minify do?
Minify removes the spaces and line breaks between tags so the XML takes up as little room as possible. The result holds the same elements and data, which is useful when size matters, such as sending XML in a request or storing it in a field.
What is well-formed XML?
Well-formed XML follows the basic rules of XML: every opening tag has a matching closing tag, tags are nested correctly, attribute values are quoted, and there is a single root element. Well formed is not the same as valid against a schema, but it is what most tools need before they will read the file.
Is my XML kept private?
Yes. All formatting, checking, and minifying runs in your browser. Your XML is never uploaded to a server or saved anywhere, so you can safely paste in data that contains private values. Once the page has loaded you can even use it offline.