Skip to content

XML formatter

Pretty-print messy XML with consistent indentation, check that it is well-formed, or minify it into a single compact line, all locally in your browser.

  • Free, no limits
  • No sign-up
Everything happens in your browser; your data is never uploaded.
  • ✓ Free
  • ✓ No sign-up
  • ✓ Nothing uploaded

Next step

What to do next

How to use it

  1. Paste your XML or open a file (.xml, .svg, .rss, .gpx, .kml and more).
  2. Choose Beautify or Minify.
  3. Pick the indentation and whether to keep comments.
  4. Copy or download the result.
Try it now

Format and validate in one step

Beautify puts each element on its own line and indents child elements, so the structure of a long one-line XML file becomes readable. At the same time, the browser's own XML parser checks the document. You get either a confirmation that the XML is well-formed or the parser's error message pointing to the problem.

Minify removes the whitespace between tags, and optionally the comments, to make the file smaller for transfer or storage. Text inside elements is left intact.

Because the tool runs in your browser, you can safely format invoices, configuration files and API payloads that contain private data.

XML syntax refresher

A minimal well-formed XML document looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<invoice>
  <seller name="Acme Corp."/>
  <items>
    <item qty="2">PDF tool</item>
  </items>
</invoice>
  • The optional declaration on the first line states the XML version and encoding.
  • There is exactly one root element (invoice).
  • Elements either have a closing tag (</item>) or close themselves (<seller/>).
  • Attribute values are always quoted.
  • Five characters have predefined entities: &lt; for <, &gt; for >, &amp; for &, &quot; for " and &apos; for '.
  • Tag names are case-sensitive: <Item> and <item> are different elements.

Well-formed vs. valid

These two words mean different things in XML:

  • Well-formed means the document follows XML syntax: exactly one root element, every tag closed, tags properly nested, attribute values in quotes, special characters escaped. This tool checks that.
  • Valid means the document also follows a specific schema (XSD or DTD) that defines which elements and attributes are allowed. That requires the schema file and is not checked here.

Common well-formedness errors:

ErrorExampleFix
Unclosed tag<item>AppleAdd </item>
Wrong nesting<b><i>text</b></i>Close in reverse order
Unescaped ampersandTom & JerryWrite &amp;
Unquoted attribute<item qty=2><item qty="2">
Two root elements<a/><b/>Wrap both in one root

Files you can format

XML is the base of many everyday formats, and all of them work here:

  • SVG vector graphics from design tools
  • RSS and Atom feeds
  • XML sitemaps (sitemap.xml) for search engines
  • GPX tracks from GPS devices and fitness apps, and KML files from Google Earth
  • XSD and XSL schemas and stylesheets
  • configuration files such as Maven pom.xml, Android layouts and .NET web.config
  • SOAP messages and many government or banking data exchange formats

Tips

  • Use 2-space indentation for deeply nested files; 4 spaces or tabs suit shallow documents.
  • Keep comments when you minify configuration files that others will edit later. Drop them for files that only machines read.
  • Minifying an SVG this way is safe but basic; it does not remove editor metadata or simplify paths.
  • For HTML, which is more forgiving than XML, use the HTML formatter. For JSON, use the JSON formatter.

Frequently asked questions

How do I format XML?

Paste it or open the file, keep Beautify selected, and choose 2 spaces, 4 spaces or tabs. Copy or download the formatted result.

Does it validate my XML?

It checks that the XML is well-formed and shows the parser's error if not. It does not validate against an XSD or DTD schema.

Can I format an SVG or sitemap?

Yes. SVG, RSS, Atom, sitemaps, GPX, KML and other XML-based files all work.

Will minifying change my data?

No. It only removes whitespace between tags, and comments if you choose. Element text and attributes stay the same.

Is my XML uploaded?

No. Formatting and checking run entirely in your browser.

Last updated: November 12, 2026

Recommended

Similar tools

If XML formatter helped, you may need these too.

See all in category →

People also use