How to use it
- Paste code, drop a file or load the sample; the language is preset for this page and can be changed.
- Choose format or minify and adjust indent, width and other options; the result appears on the right as you type.
- Copy or download the result; on an error, use "Go to error", fix it and run again.
Five rules of well-formed XML
The XML is checked before formatting; errors show the line and column, and "Go to error" jumps there.
| Rule | Wrong | Right |
|---|---|---|
| Exactly one root element | <a/><b/> | <root><a/><b/></root> |
| Tags close and nest properly | <a><b></a></b> | <a><b></b></a> |
| Attribute values are quoted | <a x=1> | <a x="1"> |
| Escape special characters | Tom & Jerry | Tom & Jerry |
| Match case | <Item></item> | <Item></Item> |
Languages and engines
Formatting uses the same open-source engines as popular editors, so results match Prettier in VS Code and your team can keep one style. Every engine loads from this site and runs in your browser.
| Language | Format | Compress |
|---|---|---|
| HTML | Prettier 3 | ✓ comments and whitespace |
| XML | XunL XML engine | ✓ |
| CSS / SCSS / Less | Prettier 3 | ✓ CSSO restructuring |
| JavaScript / TypeScript | Prettier 3 (Babel) | ✓ Terser (JavaScript only) |
| JSON | Prettier 3 | ✓ big numbers keep precision |
| YAML | Prettier 3 | — (comments kept) |
| SQL | sql-formatter (14 dialects) | — |
Frequently asked questions
Does it validate against an XSD?
It checks that XML is well-formed: tags match and nest, attributes are quoted and there is one root. Validity against an XSD or DTD needs a dedicated validator.
Does formatting change the data?
Elements, attributes and text stay the same; only indentation and line breaks change. Whitespace-only text nodes are dropped and unquoted values get double quotes. Check whitespace-sensitive documents such as xml:space="preserve" first.
Is my code uploaded?
No. The engines download from this site and run in your browser; your code never passes through our servers or any third party, so it is safe for internal code and configuration.
How large can files be?
Up to 5 MB per file; above 300 KB the page waits for the button instead of formatting as you type, to keep the browser responsive.
What is the difference between XML and JSON?
Both are structured data formats. XML wraps content in matching start and end tags and supports attributes, namespaces, comments and XSD schema validation; it is common in sitemaps, RSS, Office documents and banking or government interfaces. JSON uses braces and brackets for objects and arrays, is shorter and easier to read, and is used by most modern web APIs. The same data is usually longer in XML.