XML Formatter
Beautify, minify and validate XML online, free and private.
Paste messy or minified XML and turn it into clean, indented code in one click. Choose 2 spaces, 4 spaces or tabs, put each attribute on its own line and turn empty tags into self-closing ones. Need the opposite? Minify your XML to make it smaller, or click Validate to check that every tag is closed and nested correctly. Your code is formatted in your browser and never uploaded. The tool is free, with no sign-up.
No Sign-Up, No Install
Plus a Well-Formed Check
XML Never Leaves Your Browser
2 Spaces, 4 Spaces or Tabs
Tip: press Ctrl + Enter inside the input box to beautify. You can also drop a file onto the input.
Private by design: your code is formatted in your browser and never uploaded. Protected by Cloudflare Turnstile.
How Do You Format XML Online?
To format XML online, paste your code into the XML input box or click Upload to open an .xml file, choose your indentation and options under Settings, then click Beautify XML. The clean, indented code appears in the Result box, ready to Copy or Download. Click Minify XML for a compact version instead, or Validate to check that your XML is well-formed.
XML is often hard to read: returned on a single line by an API, exported from a database or CMS, or generated by a tool with no line breaks at all. An XML formatter, also called an XML beautifier, pretty printer or XML viewer, gives every element and attribute a consistent, indented layout so you can see the tree structure, find the value you need and spot mistakes quickly. An XML minifier does the reverse, removing whitespace and comments so the file is smaller to store or send.
Everything happens on your own device. Beautify, Minify and Validate run on Teasoft’s own lightweight code in your browser, so the formatter works even on large API responses without a round trip to a server. Your XML is not sent to Teasoft or anyone else, so you can safely format API responses, configuration files, sitemaps and feeds that contain private data.
What changes in your XML:
| Part of your XML | When you beautify | When you minify |
|---|---|---|
| Indentation and line breaks | Rebuilt with 2 spaces, 4 spaces or a tab for each nesting level. | Removed between tags, so the document fits on one line. |
| Elements and attributes | One element per line, and each attribute on its own line if you choose. | Kept, with extra spaces between attributes removed. |
| Empty elements | Kept as <a></a>, or turned into <a/> if you choose. | Same choice as when you beautify. |
| Comments | Kept where they are. | Removed when Remove comments when minifying is ticked. Untick it to keep them. |
| XML declaration, CDATA and processing instructions | Kept exactly as written. | Kept exactly as written. |
| Element names, attribute values and text | Unchanged. | Unchanged. |
Common reasons to format XML
- Reading a SOAP or REST API response that arrives as one long line.
- Checking an XML sitemap or RSS feed before submitting it to Google Search Console or a feed reader.
- Tidying configuration files such as Maven pom.xml, web.config, Android layouts or Spring beans before a code review or Git commit.
- Finding an unclosed tag, a mismatched end tag or an unescaped & that stops a file from loading.
- Minifying XML or SVG before sending it over the network or storing it, to cut the file size.
- Learning XML by seeing elements, attributes and nesting laid out clearly.
What each control does:
| Control | What it does | When to use it |
|---|---|---|
| XML input box | Holds the XML you want to format | Paste or type code, or drop an .xml, .svg, .xsd, .xsl, .xslt, .rss or .txt file onto it. |
| Upload, Paste, Sample and Clear | Opens a file, pastes from the clipboard, loads an example or empties the box | Click Sample to try the tool before using your own XML. |
| Indentation | Sets 2 spaces, 4 spaces or a tab for each nesting level | Match the code style of your project or team. |
| End with a new line | Adds a line break at the end of the result | Keep it on for files you save in Git or open in code editors. |
| Each attribute on its own line | Places every attribute of an element on a separate line | SVG files, Android layouts and other elements with many attributes. |
| Turn <a></a> into <a/> | Writes empty elements as self-closing tags | Shorter, tidier output for empty elements. |
| Remove comments when minifying | Strips <!– comments –> from minified XML | Leave it ticked for the smallest file. Untick it to keep notes and licence text. |
| Beautify XML, Minify XML and Validate | Formats, compresses or checks your XML | Beautify to read, Minify to ship, Validate to find errors. |
| Copy, Download and Use as input | Copies the result, saves it as a file or moves it back into the input box | Use as input to run another step, such as Validate and then Minify. |
Good to know
- Formatting does not change your data. Element names, attribute values and text stay the same. Only the whitespace between tags changes.
- Validate checks well-formedness, not a schema. It confirms that tags are closed, nested and quoted correctly, but does not test your XML against an XSD or DTD.
- Whitespace can matter. If your XML uses xml:space="preserve" or mixes text and tags, check the result before replacing the original.
- Comments are kept when you beautify. They are only removed when you minify with Remove comments when minifying ticked.
- Shortcut: press Ctrl + Enter inside the input box to beautify straight away.
What You Can Do With This Tool
- Format XML for free. No software to install and no account needed.
- Beautify XML into a clean, indented tree that is easy to read.
- Minify XML to remove whitespace and make files smaller.
- Validate XML and find unclosed or mismatched tags.
- Choose your indentation: 2 spaces, 4 spaces or tabs.
- Put each attribute on its own line for long, busy elements.
- Self-close empty tags, turning <a></a> into <a/>.
- Remove or keep comments when you minify.
- Open any XML-based file: .xml, .svg, .xsd, .xsl, .xslt and .rss.
- Copy or download the result in one click.
- Keep your code private. XML is formatted in your browser and never uploaded.
- Works everywhere: Windows, Mac, Linux, Android and iPhone.
Which Formatter Should I Use?
Use the XML Formatter for XML, SVG, RSS feeds, sitemaps and config files. For other languages, pick the matching Teasoft formatter:
How to Format XML (3 Steps)
Add your XML
Paste your code into the XML input box, drop a file onto it or click Upload. Click Sample to try an example first.
Choose your settings
Pick 2 spaces, 4 spaces or tabs, and decide whether to put attributes on their own lines and self-close empty tags.
Beautify, then copy or download
Click Beautify XML or press Ctrl + Enter. Copy the clean result or Download it as an .xml file.
Tip: if Beautify shows an error, click Validate to see where your XML breaks. The most common causes are a missing closing tag, an end tag that does not match its start tag, an unquoted attribute value and a bare & that should be written as &. Working with an API that returns JSON instead? Use the JSON Formatter.
Which Option Should I Use?
| Task | Use | Why |
|---|---|---|
| Read an API response or log that is on one line | Beautify XML | Indents every element so you can follow the tree. |
| Make a file smaller to send or store | Minify XML | Strips whitespace, and comments if ticked, without changing the data. |
| Find out why a file will not load | Validate | Points to the unclosed, mismatched or badly quoted tag. |
| Review elements with many attributes | Each attribute on its own line | Makes long tags, such as SVG paths or Android views, easy to scan. |
| Tidy empty elements | Turn <a></a> into <a/> | Gives shorter, consistent output. |
| Match your project’s code style | Indentation: 2 spaces, 4 spaces or Tab | Keeps Git diffs small and reviews clean. |
| Run another step on the result | Use as input | Beautify, check, then minify without copying and pasting. |
Getting better results when you format XML
- Paste the whole document. Snippets with more than one root element or a missing end tag will not validate.
- Keep the declaration first. The <?xml version="1.0" encoding="UTF-8"?> line must be at the very top, with nothing before it.
- Escape special characters. Write & as & and < as < inside text and attribute values.
- Wrap code in CDATA. Put scripts or HTML snippets inside <![CDATA[ ... ]]> so they are not read as tags.
- Validate before you minify. Fix errors first so your compact file is well-formed.
After you format your XML
- Check the result. Compare it with the original if whitespace inside text matters to your app.
- Minify for production. Click Use as input, then Minify XML to get a compact copy to deploy.
- Keep your style consistent. Use the same indentation for every file in a project so Git diffs stay small.
- Format related files. Use the JSON Formatter for API data and the HTML Formatter for web pages.
Frequently Asked Questions
How do I format XML online?
Paste your XML into the XML input box or click Upload, choose your indentation under Settings, then click Beautify XML. Copy or download the clean result from the Result box.
Is Teasoft's XML Formatter free?
Yes. It is completely free, with no sign-up and no limit on how often you use it.
Is my XML uploaded to a server?
No. Your XML is formatted, minified and validated inside your browser on your own device. It is never sent to Teasoft or anyone else.
What is the difference between beautify and minify?
Beautify adds line breaks and indentation so XML is easy to read. Minify removes them, and comments if you choose, so the file is as small as possible. Both keep your data the same.
Can I unminify XML?
Yes. Paste the minified XML and click Beautify XML. The tool rebuilds the indentation from the tag structure. Comments that were removed earlier cannot be brought back.
Does formatting change my XML data?
No. Element names, attributes, values, text, CDATA and processing instructions stay the same. Only the whitespace between tags changes, so parsers read the file the same way.
What does Validate check?
It checks that your XML is well-formed: one root element, every start tag closed by a matching end tag, correct nesting, quoted attribute values and escaped special characters. It does not check your XML against an XSD schema or DTD.
Can I put each attribute on its own line?
Yes. Tick Each attribute on its own line under XML options. It is useful for SVG files, Android layouts and other elements with many attributes.
Can I use tabs instead of spaces?
Yes. Choose Tab under Indentation, or pick 2 or 4 spaces to match your project.
Are XML comments kept?
Yes. Beautify keeps every comment where it is. Minify removes comments only when Remove comments when minifying is ticked.
Can I format SVG, RSS, XSD or XSLT files?
Yes. They are all XML, so you can open .svg, .rss, .xsd, .xsl and .xslt files, as well as .xml and .txt, and format them the same way. Sitemaps and SOAP messages work too.
Why does Beautify or Validate show an error?
Your XML is not well-formed. Look for a missing or mismatched end tag, an unquoted attribute value, a bare & character or text before the <?xml?> declaration. Fix it and try again.
How do I save the formatted XML?
Click Download in the Result box to save it to your device as an .xml file, or click Copy to paste it straight into your code editor.
Does it work with XML namespaces?
Yes. Namespace prefixes and xmlns declarations are kept exactly as written, so SOAP envelopes, XSLT stylesheets and Office XML stay valid.
Can I format XML on my phone?
Yes. It works in Chrome and Safari on Android and iPhone. Paste your XML or tap Upload to open a file from your phone.
Do I need to install any software?
No. Everything runs in your web browser. There is nothing to download or install, and no account is needed.
Which browsers are supported?
It works in Chrome, Edge, Firefox, Safari and other modern browsers on Windows, Mac, Linux, Android and iOS.
Is there a keyboard shortcut?
Yes. Press Ctrl + Enter inside the input box to beautify your XML straight away.
About Teasoft's XML Formatter
Teasoft's XML Formatter is a free online tool to beautify, minify and validate XML. It turns minified or messy XML into clean, indented code with 2 spaces, 4 spaces or tabs, can put each attribute on its own line and self-close empty elements, and checks that your document is well-formed before you use it.
It is made for anyone who works with XML: developers reading API responses and SOAP messages, SEO specialists checking sitemaps and RSS feeds, Android and Java developers tidying layouts and pom.xml files, designers cleaning up SVG code, and students learning how XML is structured.
Your XML is processed on your device and is never uploaded. A quick Cloudflare Turnstile check keeps the tool free from abuse, and there is nothing to install and no account to create.