XML Formatter
Use the CaseSwitch XML Formatter to indent well-formed XML so SOAP responses, SVG, and config files are readable. Paste XML, choose Pretty or Minify, and copy the result. Formatting runs in this browser — nothing is uploaded.
Written by the CaseSwitch editorial team. We maintain these tools in the browser so drafts, keys, and images stay on your device.
Last reviewed: 23 July 2026
Processed locally in your browser. Nothing is sent to a server.
Paste or type text to convert. Output stays empty until there is input.
Character count: 0 · Word count: 0 · Line count: 0
Examples
Nested elements
Input
<root><a>1</a><b>2</b></root>
Output
<root>
<a>
1
</a>
<b>
2
</b>
</root>Minify a tiny tree
Input
<root> <a/> </root>
Output
<root><a/></root>
Declaration plus note
Input
<?xml version="1.0"?><note><to>Ada</to><from>Bob</from></note>
Output
<?xml version="1.0"?>
<note>
<to>
Ada
</to>
<from>
Bob
</from>
</note>SVG fragment
Input
<svg><circle cx='1' cy='1' r='1'/></svg>
Output
<svg> <circle cx='1' cy='1' r='1'/> </svg>
Self-closing items
Input
<items><item id='1'/><item id='2'/></items>
Output
<items> <item id='1'/> <item id='2'/> </items>
How to use
- Paste well-formed XML into the input panel.
- Use Pretty print to indent, or Minify to collapse whitespace.
- Copy the result. Fix mismatched tags if formatting looks wrong or fails.
What this tool is for
XML is still common in enterprise APIs, build files, and SVG. Pretty-printing makes nested elements obvious. This page indents a well-formed document; it is not an XSD validator and will not invent missing closing tags.
How it works
Pretty mode runs a basic indent pass that increases depth on opening tags and decreases on closing tags. Self-closing tags stay leaf nodes. Minify collapses whitespace and tightens tag gaps. Attribute quotes are left as you pasted them when the indent pass does not rewrite them.
When to use it
Debugging an API that still speaks XML, cleaning an SVG you will edit by hand, reading a Maven pom snippet, and comparing two responses visually.
When not to use it
HTML is not XML (unless XHTML) — use the HTML Formatter. Do not format a huge export in a browser tab. Schema validation belongs in xmllint or your IDE.
How it compares to related tools
HTML Formatter is more lenient with web markup. JSON Formatter and YAML Formatter are different data models. SVG often lives happily here when it is well-formed XML.
Common mistakes
Forgetting that unescaped `&` breaks well-formedness. Pretty-printing SVG in a way that changes significant whitespace in text nodes (rare but real with `xml:space`). Expecting HTML void tags without `/` to parse as XML.
Well-formed vs valid
Well-formed means tags nest and special characters are escaped. Valid means the document matches an XSD/DTD. This tool targets readability of well-formed XML. Schema checks stay in your toolchain.
SVG and whitespace
Most SVG path and shape markup tolerates indentation. Text-heavy SVG with `xml:space="preserve"` can change appearance if you insert newlines inside text nodes — review those files carefully after pretty-print.
Frequently asked questions
Why won’t my file format?+
Unescaped `&`, mismatched tags, or HTML-style void tags without proper XML form. Fix well-formedness first.
Does this validate against a schema?+
No. It only pretty-prints or minifies the text structure.
Is HTML accepted?+
Only if it is well-formed like XHTML. Everyday HTML belongs on the HTML formatter.
What does minify do?+
It collapses whitespace runs and removes spaces between adjacent tags. It does not compress with a binary XML encoding.
Is my XML uploaded?+
No. Formatting runs in this browser.
Will attribute order change?+
The indent pass keeps attributes on the tag text as pasted. Do not rely on attribute order as a security boundary.
Does this tool send my payload to CaseSwitch?+
No. Formatting, encoding, and naming conversions for this page run in your browser after load — your sample stays on the device.
Related guides
Read our original articles on this topic.
Related tools
YAML Formatter
Cleaning a workflow file snippet, reviewing a Helm values fragment, normalizing list indentation, and teaching YAML structure on a short sample.
HTML Formatter & Minifier
Cleaning an email HTML snippet, reviewing a CMS export, shrinking a static fragment for a demo, and making a nested list readable before you edit it by hand.
JSON Formatter
Debugging a 401 response, comparing two configs, preparing a gist, shrinking a JSON blob before embedding it in a test fixture, and checking whether a file is actually JSON before you commit it. If you need to escape a string as a JSON literal, use JSON Stringify instead. If you need YAML, use JSON to YAML after the JSON is valid.
JavaScript Formatter
Reading a minified function from DevTools, cleaning a gist, sharing a snippet in a ticket, and normalizing a short example before a PR comment.
TypeScript Formatter
Cleaning a type copied from a library .d.ts, reviewing a generic-heavy snippet, preparing a PR comment, and normalizing a short TSX-ish example.
CSS Formatter
Inspecting a production CSS file, cleaning a snippet from Stack Overflow, teaching cascade with readable examples, and preparing a small style review.
SCSS Formatter
Cleaning a mixin you copied, reviewing a theme file fragment, preparing a style PR comment, and teaching nesting with a readable example.