XML Formatter
Beautify, minify and validate XML, keeping comments and CDATA, with line and column locations for syntax errors.
0 characters · 1 line
Shortcut: Ctrl/⌘ + Enter to format
How to use
- Paste XML into “Input XML”, or click “Example” to try it.
- The result appears instantly. Syntax errors show the line, column and reason, such as unmatched tags or unquoted attributes.
- Click “Format” for indented output, or “Minify” to remove the whitespace between tags.
- Choose an indent, or turn on “Remove comments”.
- 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 & 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 an error?
is an HTML entity. XML only has five built in: <, >, &, " and '. Use the character reference   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.
Related tools
JSON Formatter
Beautify, minify and validate JSON with precise line and column error locations.YAML Formatter
Validate and beautify YAML: consistent indentation and quotes, comments kept, and syntax errors pinned to a line and column.HTML Entities
Escape < > & and other characters as HTML entities or decode them back. Supports all 2,125 named and numeric references, with a quick reference.