Skip to main content
Tools

XML Formatter

Beautify, minify and validate XML, keeping comments and CDATA, with line and column locations for syntax errors.

Indent

0 characters · 1 line

How to use

  1. Paste XML into “Input XML”, or click “Example” to try it.
  2. The result appears instantly. Syntax errors show the line, column and reason, such as unmatched tags or unquoted attributes.
  3. Click “Format” for indented output, or “Minify” to remove the whitespace between tags.
  4. Choose an indent, or turn on “Remove comments”.
  5. Click “Copy” or “Download” to grab the result.

FAQ

Is my XML uploaded?

No. Formatting and validation happen in your browser and your data never leaves your device. The tool never downloads DTDs, expands entities or runs anything, so it is safe to use on XML from unknown sources.

Can formatting change my data?

No. Text, CDATA sections, comments, processing instructions, the DOCTYPE and entity references such as &amp; are kept exactly; only the whitespace between tags and the indentation change. Mixed content (text and tags together, such as <p>Hello <b>world</b></p>) and elements with xml:space="preserve" may rely on their whitespace, so they stay on one line as written.

Which errors are detected?

The tool checks that the XML is well-formed: matching tags, quoted and unique attributes, a single root element, properly escaped & and <, valid entity and character references, declared namespace prefixes and more. It does not validate the content against a DTD or XML Schema.

Why is &nbsp; an error?

&nbsp; is an HTML entity. XML only has five built in: &lt;, &gt;, &amp;, &quot; and &apos;. Use the character reference &#160; instead, or declare the entity in a DOCTYPE.

Can I format SVG, RSS or Android layout files?

Yes. They are all XML, so any well-formed file can be formatted. Lines and columns start at 1, and columns count characters, so a Chinese character or an emoji counts as one.

Keyboard shortcuts

/
Search tools (on a tool page, goes to the homepage search)
?
Show this help
Esc
Close a dialog
Ctrl / ⌘Enter
Run the tool's main action (where supported)

While you type in a text field, / and ? are typed as usual.