1. Home
  2. Developer
  3. XML Formatter

XML Formatter

Pretty-print XML with clean indentation and spot syntax errors.

For every format and option in one place, use Code Formatter and Checker →

Runs in your browser · No upload
Result
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <!-- 메인 --> <url> <loc>https://example.com/</loc> <lastmod>2026-10-05</lastmod> <changefreq>daily</changefreq> <priority>1.0</priority> </url> <url> <loc>https://example.com/search?q=xml&amp;page=2</loc> <lastmod>2026-09-28</lastmod> </url> <url> <loc>https://example.com/about</loc> <image:image xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"> <image:loc>https://example.com/logo.png</image:loc> </image:image> </url> </urlset>
Elements
13
Attributes
2
Max depth
4
Input size
528 B
Output size
603 B

Beautify drops whitespace-only lines between tags and trims text. Add xml:space="preserve" to elements where whitespace matters and they are left untouched.

Your XML is checked and formatted in this browser and never uploaded.

How to use

  1. Paste XML into the input | a sitemap.xml, an RSS feed, an Android layout, a Maven pom.xml, a SOAP response.
  2. Beautify puts each element on its own line with indentation. Elements that contain only text stay on one line, like <title>News</title>.
  3. Minify removes only the line breaks and indentation between tags. Text content is never touched.
  4. If the XML isn’t well-formed, you get the line and column of the problem with the spot highlighted, instead of a result.

Well-formedness rules

Checking uses your browser’s built-in XML parser (DOMParser), which follows the W3C XML 1.0 rules.

Rule Wrong Right
Every element must be closed <br> <br/> or <br></br>
Tag names are case-sensitive <Item></item> <item></item>
Elements must nest, not overlap <b><i>text</b></i> <b><i>text</i></b>
Exactly one root element <a/><b/> <root><a/><b/></root>
Attribute values need quotes <a id=1> <a id="1">
Escape & and < <q>A & B</q> <q>A &amp; B</q>
Names can’t start with a digit <1st/> <first/>

A very common sitemap error is a URL like ?a=1&b=2 where the & wasn’t written as &amp;.

Things to watch out for

  • Beautify drops whitespace-only lines between tags and trims spaces around text. Add xml:space="preserve" to any element where whitespace matters and its contents are kept exactly as written.
  • Entities (&amp;, &lt;) and CDATA sections are kept as-is, never decoded, so your data doesn’t change.
  • This checks well-formedness only. It doesn’t validate against an XSD or DTD schema.

FAQ

Is my XML executed or uploaded?

No. The XML is parsed for checking only and never inserted into the page, and no external DTDs or resources are fetched. Nothing is sent to a server.

Can I format JSON or HTML too?

Use the JSON Formatter for JSON and the HTML Beautifier & Minifier for HTML. HTML allows unclosed tags like <br>, so it fails XML rules.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.