Data
XML Formatter & Beautifier
Pretty-print any well-formed XML document with consistent indentation.
Press ⌘ Enter to run
5 lines · 194 chars
Ready — press Run or ⌘ Enter
How this tool handles files
- Processing
- In your browser, on-device
- Storage
- Nothing stored
- Output
- A file you download
- Your responsibility
- Review before official use
- Runs in your browser. Your file is processed on your own device and, on this site, is not uploaded to our servers.
- Nothing is stored. Your file and its output are gone the moment you close or reload the page.
- Review sensitive files (bank, ID, medical) and check the output before sharing it.
Every tool on FormatOS runs in your browser. Read our Privacy Policy and File Handling Policy.
Common uses
- Make minified XML readable
- Inspect XML payloads while debugging
Limitations
- Input must be well-formed XML
When XML pretty-printing earns its place in your workflow
This tool takes well-formed XML and re-emits it with consistent two-space indentation so the structure becomes legible. The most common fit is debugging: when an API hands you a minified SOAP envelope, an RSS or Atom feed, or a single-line config blob, pasting it here turns a wall of angle brackets into an indented tree you can actually read and trace tag by tag.
It suits developers and integrators inspecting payloads, but also office and admin work where XML shows up indirectly — sitemap files, sitemap-style exports, plugin or app configuration files, and the XML parts inside documents. If you are preparing a sample to paste into a ticket, a code review, or a piece of documentation, the indented output reads far better than the raw stream.
It is a formatter, not a transformer. It does not change your data, merge nodes, or convert XML into another format. If you need XML turned into JSON, YAML, or a table, that is a separate conversion tool; this one exists purely to make existing XML readable while leaving its content intact.
Paste or drop, format, then copy or download
The flow is direct: paste your XML into the input area or drop an .xml file onto the page, run the formatter, and copy the result or download it as a file. Everything runs in your browser using the built-in DOMParser and XMLSerializer — no XML is uploaded to a server, and nothing persists once you close the tab.
Before indenting, the tool parses the document and checks for a parser error. If the XML is not well-formed — a missing closing tag, an unescaped ampersand, mismatched nesting — it reports the input as invalid rather than guessing. Valid documents are serialized and then indented by two spaces per nesting level, with each element placed on its own line.
Be clear on what it deliberately does not do. It does not validate against a DTD or XSD schema, so a document can be well-formed and still format cleanly even if it violates a schema. It does not wrap long attribute lists onto separate lines, reorder attributes, or rewrite namespaces, and it has no toggle for tab indentation or custom widths — the output is a single, predictable two-space style.
Where it can trip you up
The biggest constraint is the well-formed requirement. HTML fragments, JSX, or templating snippets with unclosed tags or bare attributes will be rejected; this is an XML formatter, not a lenient cleanup tool. An XML declaration or comments at the top are fine, but stray content before the root element or two root elements will fail parsing.
Whitespace handling has edge cases. Significant whitespace inside text nodes and the contents of CDATA sections are preserved as-is, which is correct but means mixed content (text interleaved with child elements) may not indent as neatly as pure element trees. Re-formatting already-formatted XML can also shift existing inline spacing, so treat the output as the new canonical layout rather than a minimal diff against your original.
Encoding and scale are practical limits too. The parser follows the document's declared encoding, so a file saved as something other than UTF-8 but declared as UTF-8 (or vice versa) can mangle non-ASCII characters before formatting even begins. Because the entire document is parsed in memory in the browser, very large files can be slow or strain a tab; for multi-megabyte XML, expect a pause or split the file first.
Checking the output before you trust it
Confirm the document was actually formatted, not rejected — if you saw an invalid-XML message, the original was not well-formed and nothing was reformatted. Then scan that the root element opens and closes once, the indentation depth matches the nesting you expect, and no elements are missing. Spot-check any non-ASCII characters, accented names, currency symbols, or emoji to confirm encoding survived the round trip intact.
If your text nodes carried meaningful whitespace, line breaks, or CDATA, verify those blocks read the same as before, since the formatter only adds structure between tags and should not have altered their contents. Compare the count of a few repeated elements against the source to make sure indentation did not visually hide a truncation.
For anything official or financial — invoices, regulatory filings, banking or e-invoicing XML, signed documents — treat formatting as cosmetic only and verify against the authoritative copy. Re-indenting can change byte-for-byte content, which will break a digital signature or hash; never replace a source-of-record file with a beautified version without confirming it still validates in the system that consumes it.
Frequently asked questions
No. It only re-indents the document so the nesting is easy to read. Elements, attributes, and text content are unchanged.
Yes. The XML must parse cleanly; if it isn't well-formed you'll see an error so you can fix the markup first.
Yes. Run the formatted output through the XML Minifier to strip the added whitespace back out for compact transport.
No. The conversion runs in your browser — your text or file is processed on your own device and, on this site, is not uploaded to a server, and we do not intentionally store it.
Related data tools
Tool last reviewed: June 30, 2026 · Report a problem