DeveloperKit

XML Formatter & Validator

Beautify, minify, and validate XML online. Free, instant, and 100% in your browser.

Input XML

1 lines · 0 B

Output

Formatted XML will appear here.

What is an XML Formatter?

XML (Extensible Markup Language) is used for SOAP APIs, RSS feeds, SVG images, office documents, Android layouts, Maven builds, sitemaps, and countless configuration files. Machine-generated XML often arrives on a single line, which makes it almost impossible to read or debug.

This XML formatter indents your document so its structure is clear, and checks it for syntax errors at the same time. When something is wrong, you see exactly where and why.

Features

  • Strict validation

    Checks well-formedness as you type: unclosed and mismatched tags, duplicate attributes, unescaped & and <, and more.

  • Exact error location

    Every error shows its line and column with a clear explanation, and Go to error jumps straight to it.

  • Beautify and minify

    Indent with 2, 3, or 4 spaces or tabs, or remove whitespace between elements to shrink the file.

  • Safe formatting

    Comments, CDATA, processing instructions, and DOCTYPE are kept. Mixed content and xml:space="preserve" stay exactly as written.

  • Works with any XML

    Format SOAP and WSDL messages, RSS and Atom feeds, SVG, Maven and Android files, sitemaps, and config files.

  • Private by design

    Everything runs locally in your browser. Your XML is never uploaded or stored.

XML Formatting Example

Minified XML
<note priority="high"><to>Ada</to><from>Alan</from><body>See you at <b>noon</b>!</body></note>
Formatted XML
<note priority="high">
  <to>Ada</to>
  <from>Alan</from>
  <body>See you at <b>noon</b>!</body>
</note>

The <body> element mixes text and a child element, so it is kept on one line to preserve its exact text.

How to Format XML Online

  1. Paste your XML into the Input editor, or upload or drop an .xml file.
  2. The tool validates it instantly and shows any error with its line and column.
  3. Choose Beautify or Minify, and pick your preferred indentation.
  4. Copy the result to your clipboard or download it as a file.

Common XML Syntax Errors

ErrorHow to fix it
<a><b></a>Close elements in the reverse order they were opened: <a><b></b></a>.
AT&TEscape a literal ampersand as &amp;, for example AT&amp;T.
<item id=5/>Wrap every attribute value in quotes: <item id="5"/>.
&nbsp;HTML entities are not defined in XML. Use &#160; or declare the entity in a DTD.
<a/><b/>An XML document must have exactly one root element. Wrap both in a parent.
Text before <?xml ...?>The XML declaration must be the very first thing in the file, with no spaces before it.

Frequently Asked Questions

What does an XML formatter do?

An XML formatter rewrites XML with consistent indentation and line breaks so nested elements are easy to read. This tool also validates the XML and reports the exact line and column of any syntax error.

What is the difference between well-formed and valid XML?

Well-formed XML follows the XML syntax rules: one root element, properly nested and closed tags, quoted attributes, and escaped special characters. Valid XML is also checked against a schema (XSD or DTD). This tool checks well-formedness, which is what every XML parser requires.

Will formatting change my data?

No. Only whitespace between elements is changed. Comments, CDATA sections, processing instructions, and the DOCTYPE are preserved. Elements that mix text and child elements, and elements with xml:space="preserve", are kept exactly as written because their whitespace can be meaningful.

Why does &nbsp; cause an error?

XML only predefines five entities: &lt;, &gt;, &amp;, &quot;, and &apos;. HTML entities such as &nbsp; or &copy; are not part of XML unless they are declared in a DTD. Use numeric references like &#160; instead.

Is my XML uploaded anywhere?

No. Parsing and formatting run entirely in your browser using JavaScript. Your XML never leaves your device.

  • XML Comparer

    Compare two XML documents side by side and see every changed element, attribute, and value.

  • JSON to XML

    Convert JSON to well-formed XML with custom root and item names, attributes, and indentation.

  • XML to JSON

    Convert XML to JSON with attributes, repeated elements as arrays, and automatic number and boolean detection.

  • XML to YAML

    Convert XML documents and configs into clean, readable YAML.