XML Formatter and Beautifier
Format XML online with 2 spaces, 4 spaces or tabs. Nested elements, attributes, comments, CDATA sections and the XML declaration are laid out clearly so the structure is visible at a glance.
Format, beautify, validate and minify XML online. Paste your code and get clean, readable XML in one click. Fast, free and no signup.
Paste your XML into the editor or load the sample.
Pick Format or Minify, set the indentation and options.
Check the validation result, then copy or save the XML.
This free XML formatter turns messy, minified or single-line XML into clean, indented code that is easy to read. Paste your XML, click Format XML and the tool will pretty print it with the indentation you choose and check at the same time that it is well-formed. It works as an XML beautifier, an XML validator and an XML minifier in one page, runs entirely in your browser and needs no signup, no installation and no file upload. Use it for sitemaps, RSS feeds, SOAP messages, Android layouts, Maven and .NET configuration files, SVG images and any other XML data.
Minified XML from an API, a long sitemap, an RSS feed or a config file is almost impossible to read in one line. This free XML formatter and beautifier adds clean indentation, checks that the XML is well-formed and can also minify it again for production. It works in your browser on Windows, Mac, Linux, Android and iPhone, handles CDATA, comments and the XML declaration safely, and never uploads your code.
Format XML online with 2 spaces, 4 spaces or tabs. Nested elements, attributes, comments, CDATA sections and the XML declaration are laid out clearly so the structure is visible at a glance.
Every time you format, the tool checks that your XML is well-formed and shows the line and column of the first error, such as a missing closing tag or an unquoted attribute.
Switch to Minify mode to remove indentation, line breaks and extra spaces. The result is a compact XML string that is ideal for API requests, config files and smaller downloads.
XML (Extensible Markup Language) is a text format that stores data in a tree of nested elements. Computers do not care how that text is laid out, but people do. When XML is generated by a program, copied from an API response or minified to save space, it often arrives as one long line with no indentation, which is very hard to read, review or debug. An XML formatter, also called an XML beautifier or XML pretty printer, rewrites the same XML with line breaks and indentation so that each element starts on its own line and child elements are indented under their parent.
Formatting does not change the meaning of your data. The element names, attributes and text values stay the same. Only the whitespace between tags is adjusted, which is why formatted and minified XML are treated as the same document by almost every XML parser.
Developers, testers, SEO specialists and system administrators open XML files every day. A formatter makes these tasks faster:
XML is strict. A single mistake makes the whole document invalid, and most parsers will refuse to read it. When the validator reports an error, check the line and column it points to and look for one of these frequent causes:
| Character | Escape code | Name |
|---|---|---|
| & | & | Ampersand |
| < | < | Less-than sign |
| > | > | Greater-than sign |
| " | " | Double quote |
| ' | ' | Apostrophe |
These three tasks are related but solve different problems. This tool combines them so you do not need to switch between websites.
| Task | What it does | Best for |
|---|---|---|
| Format (beautify) | Adds indentation and line breaks | Reading, reviewing and editing XML |
| Validate | Checks that the XML is well-formed | Finding syntax errors before using the file |
| Minify | Removes whitespace and optional comments | Smaller payloads and config files |
Keep in mind that this validator checks well-formedness, which means the XML follows the basic syntax rules. It does not compare your document against an XSD or DTD schema. If you need to confirm that a file follows a specific schema, use a dedicated schema validator after fixing the syntax here.
XML and JSON are both used to exchange data, but XML uses tags and supports attributes, comments and namespaces, while JSON uses braces and key-value pairs. If your data starts with curly braces, use the JSON Formatter instead. HTML looks similar to XML but is more forgiving, so for web pages use the HTML Formatter, and to shrink a page use the HTML Minifier. For stylesheets and scripts you can use the CSS Formatter and the JavaScript Beautifier.
Formatting only changes the whitespace between tags. These building blocks of an XML document are kept as they are:
| Part | Example | What the formatter does |
|---|---|---|
| XML declaration | <?xml version="1.0" encoding="UTF-8"?> | Stays on the first line. |
| Comments | <!-- note --> | Kept by default, and removed if you uncheck the option. |
| CDATA sections | <![CDATA[ 5 < 6 ]]> | Content is left exactly as written. |
| DOCTYPE | <!DOCTYPE note SYSTEM "note.dtd"> | Kept above the root element. |
| Attributes | <item id="5" type="new"> | Spacing is cleaned up, or each attribute can go on its own line. |
| Text elements | <price>19.99</price> | Stay on a single line instead of being split into three. |
The formatter is a web page, so it works on Android, iPhone, Windows, Mac and Linux without any editor plugin. Paste your XML, choose Format or Minify and copy or download the result as an .xml file. It is a quick alternative when your code editor has no XML formatter installed.
Yes. Formatting, validation and minifying run in your browser, so your XML is not sent to a server or saved. Even so, avoid pasting passwords, keys or private customer data in any online tool and replace them with sample values.
XML work often involves checking, converting and tidying other formats. These free tools can help:
Our XML formatter is free, fast and works on desktop, tablet and mobile. There is no account to create, no watermark and no software to install. Paste your XML, format or minify it, validate it and copy the result in seconds. Because the processing happens inside your browser, your data stays on your device while you work.
Find answers to common questions about formatting, validating and minifying XML online.
Paste your XML into the editor, choose the indentation (2 spaces, 4 spaces or tab) and click Format XML. The tool adds line breaks and indentation, checks that the XML is well-formed and shows the result below. You can then copy the formatted XML or download it as an .xml file.
Formatting changes only the layout of the XML by adding indentation and line breaks so it is easier to read. Validating checks whether the XML is well-formed, which means tags are properly opened and closed, attributes are quoted and there is a single root element. This tool does both at the same time: it formats your code and tells you whether it is well-formed.
The most common reasons are a missing closing tag, tags that are closed in the wrong order, tag names with different upper and lower case letters, attribute values without quotes, an unescaped ampersand or less-than sign inside text, or more than one root element. The error message shows the line and column of the first problem, so fix that one and run the tool again.
Yes. Switch the mode from Format to Minify to remove indentation, line breaks and extra spaces between tags and produce a compact single-line XML. You can choose to keep or remove comments. Minified XML is smaller, which is useful for API payloads, configuration files and data that is sent over the network.
No. Only whitespace between tags changes. Element names, attributes, text values, CDATA sections, processing instructions such as the XML declaration and the DOCTYPE are kept. Comments are kept by default, and you can uncheck the option to remove them.
No. The formatting, validation and minifying all run in your browser, so your XML is not sent to a server or saved. This makes the tool safe to use with configuration files and private data, but you should still avoid pasting passwords or secret keys on any website.
Any XML-based text can be formatted, including sitemap.xml files, RSS and Atom feeds, SOAP messages, Android layout and manifest files, Maven pom.xml files, web.config and app.config files, SVG images, XLIFF translation files and API responses that return XML.
Format XML, validate XML, format JSON or beautify HTML in seconds. Explore free developer tools to format, convert and debug your data in one place.
Explore All Developer Tools →