# XML Formatter

URL: https://tools.otaku-dojo.com/en/xml-formatter
Updated: 2026-10-03

The XML Formatter first checks that your XML is well-formed using the browser's built-in XML parser, then re-indents it with 2 spaces, 4 spaces or tabs — or minifies it to a single line. It is useful for tidying sitemap.xml, RSS, SVG, SOAP and config files, and everything stays in your browser.

## How to use the XML Formatter

1. Paste XML on the left, or press "Sample" to load a sitemap.
2. Choose the indentation and mode (Pretty or Minify).
3. The result appears instantly; if the XML is malformed, the status bar shows the line and column.
4. Press "Copy" or "Download" to save it as .xml.

## Specs & key facts

- **Check**: XML 1.0 well-formedness
- **Preserved**: Attributes, comments, CDATA, processing instructions and the XML declaration
- **Indentation**: 2 spaces, 4 spaces, Tab, or minified
- **Not included**: DTD / XSD schema validation
- **Processing**: In your browser (nothing is uploaded)
- **Price**: Free, no sign-up

## Examples: Pretty-print one-line XML

```xml
<note><to>Tove</to><from>Jani</from><body>Hi!</body></note>
```

→

```xml
<note>
  <to>Tove</to>
  <from>Jani</from>
  <body>Hi!</body>
</note>
```

## FAQ

### What is the difference between well-formed and valid XML?

Well-formed means tags are closed, properly nested and escaped. Valid also means it matches a DTD or XSD schema. This tool checks well-formedness.

### Does formatting change my XML content?

Only whitespace between tags. Leading and trailing whitespace in text nodes is trimmed, so if your data depends on it (for example xml:space="preserve"), check with Minify mode.

### Can I use it for sitemap.xml or SVG?

Yes. Sitemaps, RSS, Atom and SVG are all XML and can be formatted and checked here.

### Does it work with HTML?

Only XHTML that follows XML rules. Regular HTML allows unclosed tags such as <br>, which are reported as errors.
