How to use it
- Paste your XML into the large box, or open a file from your computer with "choose an .xml file". Choosing a file formats it immediately.
- Pick the indentation: 2 spaces, 4 spaces or a tab. Most projects use 2 or 4 spaces.
- Press "Format XML". Each element goes on its own line and children are indented one level deeper. Above the result you will see the root element, the number of elements and attributes, and the deepest level.
- If you need to send the file to another system or reduce its size, press "Minify" to remove every unnecessary space and line break.
- Copy the result to the clipboard or download it as an .xml file.
What XML is and why you format it
XML (Extensible Markup Language) stores data as nested, tagged elements in plain text. It is everywhere: e-invoices such as UBL and Peppol documents, bank statements, RSS and Atom feeds, SVG graphics, sitemaps, Android layouts, .NET and Java configuration files, and the inside of Office documents. Because XML usually travels between machines, it is often produced as one long line with no whitespace. Reading it, finding a field or spotting a mistake by eye is then close to impossible.
Formatting, also called pretty printing or beautifying, puts each element on its own line and indents nested elements without changing what the document means. You can see at a glance which tag sits inside which, and where each item in an invoice starts and ends. Minifying does the opposite: it removes whitespace added for readability, making the file smaller and faster to transfer.
Validation and error messages
The tool uses your browser’s built-in XML parser to check that the document is well-formed. If there is an unclosed tag, elements closed in the wrong order, an unquoted attribute, an unescaped & or more than one root element, no result is produced; instead you get the parser’s message and, where available, the line number. For example, to write "Smith & Sons" inside XML, the ampersand must be written as &. This check covers structure only; it does not validate against a schema (XSD).
What is kept and what changes
- Kept: element names, namespace prefixes, attributes and their values, text content, CDATA sections, comments, processing instructions and the <?xml version="1.0" encoding="UTF-8"?> declaration at the top.
- Changed: indentation and line breaks between elements. Leading and trailing spaces inside text content are trimmed; spaces in the middle of text are left alone.
- Empty elements: an empty <tag></tag> is written in the short form <tag/>. In XML the two mean exactly the same thing.
In special documents where whitespace matters, such as text marked xml:space="preserve", the formatted version may look different. Before submitting a file to an official system, use the original produced by the source software; this tool gives you the best copy for reading and debugging.
Working with invoices and feeds
If you open an e-invoice downloaded from your accounting software and see one enormous line, load it here to quickly find the buyer, seller, tax numbers, line items and totals. Invoice XML often carries an embedded PDF and signature as long Base64 blocks; these stay on a single line in the formatted output. The same goes for RSS feeds and sitemaps: formatting makes it easy to check titles, dates and URLs. Because nothing is uploaded, your business data stays private.
Common XML mistakes
- Unclosed tags: every <item> must be closed with </item> or written as a self-closing <item/>.
- Wrong closing order: <a><b></a></b> is invalid; inner elements are closed first.
- Case mismatch: XML is case sensitive, so <Invoice> does not match </invoice>.
- Unescaped characters: & and < cannot appear as-is in text; use & and <.
- More than one root: a document needs exactly one root element.
Why use this tool?
- Your file never leaves your device. Parsing and formatting happen in your browser; nothing is uploaded or stored.
- Fast and unlimited. Files up to 5 MB, no account and no daily limit.
- Validation included. Clear messages with line numbers for broken XML.
- Works offline. Once loaded, the page keeps working without a connection.
Frequently asked questions
Does formatting change the meaning of my XML?
No. Only indentation and line breaks between elements change. Tags, attributes and text are kept; leading and trailing spaces inside text are trimmed.
What does “The XML is not valid” mean?
The text breaks the rules of well-formed XML: an unclosed tag, wrong closing order, an unquoted attribute or an unescaped & character, for example. Check the line number in the message.
Does it validate against a schema (XSD)?
No. It checks that the XML is well-formed. Schema validation, for example for e-invoice standards, needs the official XSD and a dedicated validator.
What is minifying for?
It removes whitespace added for readability and puts the XML on one line, making it smaller, faster to transfer and matching what some systems expect.
What is the maximum file size?
You can choose files up to 5 MB. Larger text can be pasted into the box, but your browser may slow down.
Are comments and CDATA kept?
Yes. Comments, CDATA sections, processing instructions and the XML declaration all appear in the formatted result.
Can I format SVG, RSS or sitemap files?
Yes. SVG, RSS, Atom, sitemaps, XSD and XSL are all XML, so they can be formatted and checked the same way.
Is my file uploaded anywhere?
No. The file is read and processed in your browser and is never sent to a server or stored.
Related tools
Need a custom tool or web software for your business? The 4D1A team can help.