XML Formatter and Beautifier
Paste XML to pretty-print or minify it instantly. Each tag is indented by nesting level, attributes and the <?xml?> declaration are preserved, and nothing leaves your browser.
How to format XML
- Paste your XML into the editor.
- Choose Format to indent it or Minify to strip whitespace, and pick an indent size.
- Copy the result or download it as a .xml file.
Examples
Beautify a one-line document
<note id="7"><to>You</to><body>Hi there</body></note>
<note id="7"> <to>You</to> <body>Hi there</body> </note>
Frequently asked questions
Is my XML sent to a server?
No. Formatting and minifying run entirely in your browser, so your XML never leaves your device.
How does the formatter decide indentation?
It scans the tags: every open tag adds one level of indent, each closing tag removes one, and self-closing tags, text and comments stay at the current level.
Does it keep the <?xml?> declaration and attributes?
Yes. The declaration is placed on its own line and attribute strings are preserved exactly as you wrote them, including quotes and spacing.
What does Minify do?
Minify removes the whitespace between tags to produce a single compact line, which is useful for shrinking payloads or storing XML in one field.
What if my XML is malformed?
If a tag is never closed or a tag is missing its closing angle bracket, you get an error message instead of broken output, so you can fix the source.
Can I change the indent size?
Yes. Pick two spaces, four spaces or tabs. The same indent string is applied at every nesting level.
Learn more
- XML vs JSON: when to use each
How XML and JSON differ in syntax, attributes, schemas and tooling, and which format fits your use case.
Related tools
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
SQL Formatter
Format and beautify SQL online. Put clauses on their own lines, indent the column list and uppercase keywords. Fast and runs in your browser.
HTML to JSX
Convert HTML to JSX for React. Rename class and for, camelCase attributes and events, turn inline styles into objects and self-close void tags.
Markdown to HTML
Convert Markdown to clean HTML in your browser. Headings, bold, italic, links, images, lists, blockquotes and fenced code blocks, with text safely escaped.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.