XML Formatter & Validator - Pretty Print XML Online
Pretty-print and validate XML
SOAP responses, sitemaps, RSS feeds and config exports often arrive on a single line. This formatter puts each element on its own line and indents children under their parents. It also runs the document through the browser's XML parser and shows the error if it is not well-formed.
Nothing important is rewritten
Formatters that rebuild the document from a parsed tree can reorder attributes, switch quote styles or expand
& into &. This one works on the source text. Each tag, entity, processing instruction,
DOCTYPE, comment and CDATA section is copied as written, and only whitespace between them changes. An element that holds just
text or one CDATA block stays on one line, as <price> does below.
How to use it
Paste XML and pick two spaces, four spaces or a tab. A green "Well-formed XML" note under the editor means the parser accepted it; otherwise the error appears above the output. Any XML works the same way: POM files, Android layouts, SVG, sitemaps, Atom feeds.
Example
Input:
<?xml version="1.0" encoding="UTF-8"?><catalog><!-- spring list --><book id="bk101" lang="en"><title>XML Developer's Guide</title><price currency="USD">44.95</price><notes><![CDATA[Use <b>bold</b> sparingly]]></notes></book><book id="bk102"/></catalog> Output (2 spaces):
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<!-- spring list -->
<book id="bk101" lang="en">
<title>XML Developer's Guide</title>
<price currency="USD">44.95</price>
<notes><![CDATA[Use <b>bold</b> sparingly]]></notes>
</book>
<book id="bk102"/>
</catalog> Minify XML
Minify removes the whitespace between tags and, if you tick Remove comments, the comments too. Text with real content is kept
exactly, including inner spaces, so <name> Jo Bloggs </name> is unchanged. Input and output sizes
are shown under the editor.
Common XML errors
- Mismatched tags: every
<tag>needs a matching</tag>with the same case. - Unescaped characters: a bare
&or<in text must be written as&or<, or wrapped in CDATA. - More than one root: an XML document must have exactly one top-level element.
- Unquoted attributes: attribute values must be in single or double quotes.
Related tools
Convert XML into JSON with the XML to JSON converter, or tidy HTML with the HTML formatter.
Related Tools
Epoch / Unix Timestamp Converter
Convert between Unix epoch timestamps and human-readable dates.
Regex Tester
Test regular expressions against text with match highlighting.
UUID Generator
Generate random v4 UUIDs for use in databases and APIs.
Colour Converter
Convert colours between HEX, RGB, and HSL formats.