Free XML Formatter, Beautifier & Minifier Online
Paste XML and get clean, indented output instantly. Beautify with 2, 4, or 8-space indent, minify to wire format, or validate well-formedness — on SOAP, RSS, sitemaps, Android strings.xml, SVG, and Office Open XML. 100% free, runs in your browser.
Beautify + Minify
Two-direction conversion: indent any blob of XML into readable form, or strip whitespace between tags to produce a compact wire-format payload.
Native Validation
Uses the browser's built-in DOMParser — the same XML engine the browser ships. Reports the exact location of malformed markup with line context.
Four Sample Loaders
One-click samples for SOAP envelopes, RSS feeds, XML sitemaps, and Android strings.xml — the four shapes you are most likely debugging.
100% Client-Side
XML often contains business data, auth tokens, or internal IDs — they never leave your browser. No fetch, works offline once loaded.
XML Formatter: Beautify, Minify, or Validate XML Online
An XML formatter turns minified or messy XML into clean, indented markup so the element hierarchy is readable. Paste XML, then Beautify with 2, 4, or 8-space indent, Minify to wire format, or Validate well-formedness. It parses with the browser's native DOMParser, handles SOAP, RSS, sitemaps, and SVG, and runs 100% in your browser — free, no upload.
How to format XML
- Paste your XML into the left pane, or load a sample (SOAP envelope, RSS feed, Sitemap, or Android strings.xml).
- Pick a mode: Beautify to indent, Minify to strip whitespace, or Validate to check well-formedness.
- In Beautify mode, set Indent to 2, 4, or 8 spaces — the output updates the instant you change it.
- Read the live tag count in the input header to confirm the parser sees the structure you expect.
- Press Copy to send the formatted output to your clipboard. On a syntax error the output stays empty and the failing tag is shown.
What is XML, and what does "well-formed" mean?
XML (Extensible Markup Language) is a text format for structured data, defined by the W3C XML 1.0 specification. A document is well-formed when its syntax is correct: exactly one root element, every tag closed, every attribute value quoted, and reserved characters escaped. A document is valid when it is well-formed and conforms to a DTD or XML Schema (XSD). This tool checks well-formedness only, using DOMParser; it does not validate against a schema.
Three rules trip people up most. First, every attribute value must be quoted — <item id="1">, never <item id=1>. Second, a literal & in text must be escaped as & and < as <. Third, XML is case-sensitive, so <Item> and <item>are different elements and must close with matching case. The optional XML declaration on line one, <?xml version="1.0" encoding="UTF-8"?>, names the version and character encoding.
"The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag."— W3C XML 1.0 (Fifth Edition), section 3.1. So<br></br>and<br />are equivalent.
Where XML still matters
| Use Case | Why XML |
|---|---|
| SOAP envelopes | SOAP web-service request/response payloads — still common in enterprise (banking, insurance, government APIs). |
| RSS / Atom feeds | Inspect feed XML when building feed readers or debugging Open Graph crawlers. |
| XML sitemaps (sitemap.xml) | Visually verify URL entries, lastmod dates, and priority values before submitting to search engines. |
| Android string resources | res/values/strings.xml and similar resource files — pretty-print before pull requests. |
| Maven / Gradle configs | pom.xml in Maven projects; build.gradle has XML-format dependency reports. |
| SVG source code | Inspect raw SVG markup, hand-edit the path data, and re-export with clean indentation. |
| Office Open XML (.docx) | After unzipping a .docx, .xlsx, or .pptx, the inner document.xml is highly minified — beautify to read it. |
Worked examples: input → output
Beautify · minified input
<root><a>1</a><b>2</b></root>
becomes (2-space indent):
<root> <a>1</a> <b>2</b> </root>
Beautify · empty element normalized
<item></item> → <item />
An empty tag is rewritten to the self-closing form. Per the W3C spec the two are equivalent, so this is safe and shorter.
Minify
multi-line XML → whitespace between tags removed, single-line wire format
Edge case · minify collapses inner spaces
Minify collapses all whitespace runs, including inside text nodes, to a single space: <note>Hello world</note> becomes <note>Hello world</note>. If exact internal spacing or line breaks matter (some Android string resources rely on them), wrap the value in <![CDATA[ ... ]]> before minifying, or use Beautify instead.
XML predefined entity reference
XML defines five built-in character entities. These are the only escapes guaranteed to work without a DTD. The beautifier escapes &, <, and > in text and additionally " and ' in attribute values.
| Character | Entity | Name | Required in |
|---|---|---|---|
| & | & | ampersand | text & attributes |
| < | < | less-than | text & attributes |
| > | > | greater-than | text (after ]]>) |
| " | " | double quote | double-quoted attributes |
| ' | ' | apostrophe | single-quoted attributes |
XML vs JSON — six differences that still matter
| Aspect | XML | JSON |
|---|---|---|
| Verbosity | Opening + closing tags; more characters per data point | Compact; braces, brackets, commas |
| Attributes | Native — <book id="1"> | Modeled as nested objects {id: 1} |
| Comments | <!-- comment --> supported in the spec | No comment syntax in strict JSON |
| Schema validation | XML Schema (XSD), DTD, RELAX NG — mature ecosystem | JSON Schema; less mature than XSD historically |
| Use cases | SOAP, RSS, sitemaps, Android resources, Office docs | REST APIs, web app config, NoSQL document stores |
| Parsing in browsers | Native DOMParser; produces a Document tree | Native JSON.parse; produces plain object |
The choice is rarely yours alone — the system you integrate with usually dictates the format. For a deeper comparison see our JSON vs YAML vs XML guide.
The round-trip behavior most formatters do not document
Beautify is not a byte-for-byte reformat. Two normalizations happen on every pass. (1) Empty elements collapse to self-closing form: <tag></tag> and <tag> </tag> both become <tag />. (2) Text-only elements stay inline only when the text contains no newline and is under 80 characters; at 80 or more, the text moves onto its own indented line. So <title>Short</title> stays on one line, while an 80+ character title expands.
The validator is strict on purpose. It is well-formedness only via DOMParser — it will not check your XML against an XSD or DTD, and it will not silently repair broken markup. If a tag is unclosed, you get the parser's error line, not a guessed fix. That is deliberate: auto-repairing malformed XML hides the bug that produced it.
Runs 100% in your browser
Your XML never leaves your device. Parsing uses the browser's native DOMParser and serialization uses XMLSerializer, both in JavaScript locally — no fetch, no XHR carries your markup. I tested this against the four built-in samples plus real SOAP responses with nested namespaces, RSS feeds with CDATA-wrapped HTML, and an unzipped .docx document.xml. CDATA, comments, processing instructions, and the XML declaration all round-trip intact. This matters because SOAP payloads routinely carry auth tokens, customer IDs, and internal endpoints.
Frequently asked questions
Is this XML formatter free?
Yes — 100% free with no signup. Beautify, minify, and validate run unlimited times in your browser.
Does this validate against an XSD schema?
No. It checks well-formedness only via DOMParser. For DTD or XML Schema (XSD) validation, use a schema-aware validator with your specific schema file.
Are CDATA, comments, and namespaces preserved?
Yes. CDATA sections, comments, processing instructions, the XML declaration, and both default and prefixed namespaces are kept exactly as written.
Why does my SOAP fragment fail to parse?
Usually because a namespace prefix like soap: is referenced in a child but the xmlns:soap declaration sits on the root you did not paste. Paste the full document including the root element and its xmlns declarations.
Related developer & data-format tools
Beautify & validate JSON, the modern counterpart
JSON ↔ YAML ConverterSwap between the two config formats
YAML ValidatorCheck YAML syntax the same way
CSV ↔ JSON ConverterConvert tabular data to JSON
JSON DiffCompare two JSON documents
JSON Schema GeneratorDerive a JSON Schema from sample data
JSON to TypeScriptGenerate TS interfaces from JSON
HTML FormatterSame pretty-print pipeline for HTML
SQL FormatterIndent and align SQL queries
Base64 EncoderEncode XML payloads for transport
Find and ReplaceBulk-edit namespace prefixes & attributes
Guide: JSON Validation & FormattingThe companion data-format guide
All ToolsBrowse the full Toolk hub
Last updated: June 2, 2026 · Runs 100% in your browser — no uploads, nothing leaves your device.
Need a different tool?
Browse all 89 free, in-browser tools — or tell us what we should build next.