XML Formatter
Pretty-print or minify XML with proper indentation - in your browser, no upload.
Paste XML, get a clean indented version - or click minify to collapse it back to one line. Self-closing tags, CDATA blocks and comments are preserved. The parser runs in your browser; payloads never leave your device.
How to use it
Paste your XML
Any well-formed XML, with or without an XML declaration.
Pick pretty-print or minify
Pretty-print uses 2 spaces by default; switch to 4 spaces or tabs if your codebase prefers.
Copy the result
Output appears in the right pane. Hit Copy to grab it.
What is it?
An XML formatter rewrites a string of XML in a canonical form - either indented for reading or stripped to a single line for storage / transport. The structural facts (elements, attributes, text, CDATA, comments) are preserved; only whitespace between nodes changes. Pretty-printing is the most common use; minifying is occasionally needed for shaving bytes off a payload.
When to use it
Reading a one-line XML response from an API. Comparing two XML files in a diff tool that doesn't ignore whitespace. Pasting an SVG into source control after a graphics tool wrote it as a single line. Stripping pretty-printed XML before embedding in an attribute or generating a small QR code.
Common mistakes
Treating the result as canonical XML for signature purposes - real XML canonicalisation (c14n) is a separate spec and this tool doesn't implement it. Assuming attribute order is preserved across parser implementations (it is here, but XML technically doesn't guarantee it). And running the minifier on XML that contains significant whitespace in <pre>-like content - any whitespace-sensitive content needs CDATA or escaped runs.
FAQ
- Does it validate the XML?
- It uses the browser's DOMParser, which surfaces malformed XML as a parser error. Validation against a schema (XSD, DTD, RelaxNG) is out of scope.
- What about XML namespaces?
- Namespaces are preserved on the tags that declare or use them. The formatter doesn't re-prefix or normalise them.
Related tools
More in this category
- JSON Formatter & Validator
- Base64 Encoder / Decoder
- URL Encoder / Decoder
- Hash Generator (SHA-1, SHA-256, SHA-384, SHA-512)
- JWT Decoder
- Regex Tester
- Markdown to HTML Converter
- YAML to JSON Converter
- CSV to JSON Converter
- SQL Formatter
- HTML Entity Encoder / Decoder
- Cron Expression Reader
- HTML Minifier
- Mock Data Generator
- Markdown Table Generator