🧹 XML Formatter

Indents an XML string to match its tag structure.

How to use

  1. Enter your XML string.
  2. Click "Format".
  3. You'll see the result indented to match its tag structure.

🎯 Use Cases

Example

Input
<config><host>localhost</host><debug enabled="true"/></config>
Output
<config>
  <host>
    localhost
  </host>
  <debug enabled="true"/>
</config>

A one-line minified XML string is indented by two spaces per level to match its tag hierarchy. Text inside an element moves to its own line, and empty (self-closing) tags are kept exactly as written.

XML elements and how they are tidied

Indentation follows tag nesting depth. Unlike HTML, XML requires every tag to close and is case-sensitive.

ElementHandling
Open/close tagsIndented by nesting depth
Self-closing tags<tag /> kept on one line
AttributesLeft untouched inside the tag
Comments & CDATAContent preserved as-is

FAQ

Are CDATA sections handled correctly?
Yes. CDATA sections are preserved exactly as-is, so their inner content is never restructured.
Can it format invalid (non-well-formed) XML too?
XML that isn't well-formed, such as mismatched tags, may be indented differently than expected. Check the original structure first.
Is the content I enter sent to a server?
No. It's processed entirely in your browser.
Can I tidy HTML here?
It works, but HTML has different rules (optional closing tags) — prefer the HTML formatter.
Are attributes or content changed?
No — only indentation and line breaks; tags, attributes and text stay the same.

More Coding Tools

📘
JSON Formatter
Prettify, validate & minify JSON
🗓️
Timestamp Converter
Convert Unix timestamp ↔ date
🧩
JSON String Encoder
Convert text ↔ JSON string literal
✨
JS/CSS Formatter
Indent & tidy JS/CSS code
✂️
JS/CSS Minifier
Strip comments & whitespace
🧽
HTML Formatter
Indent HTML by tag structure
🗃️
SQL Formatter
Break SQL into clauses & indent
🔣
HTML Entity Encoder
Convert special chars ↔ HTML entities
📊
Excel to HTML Table
Convert spreadsheet data to HTML TABLE
⛓️
Link Extractor
Extract href/src links from HTML
🎨
Color Picker
Get HEX, RGB & HSL color codes
🐘
PHP Syntax Checker
Check bracket/string pairing (practical checker)
🗄️
MySQL Syntax Checker
Check bracket/quote pairing (practical checker)
🔍
HTML5 Validator
Check tag pairing, duplicate id, missing alt
✍️
Online HTML Editor
Write & edit HTML visually