XML Formatter
Format and indent XML documents for better readability.
Format XML with clean, consistent indentation so it's easy to read, or minify it onto one line. Paste XML from an API response, a config file, a sitemap or a SOAP message, choose 2 spaces, 4 spaces or tabs, and copy or download the result. The XML is parsed first, so if it isn't well formed (an unclosed tag, a stray ampersand), you get an error instead of a mangled file. Formatting keeps comments, CDATA sections and the XML declaration; minifying removes comments.
Common use cases
- Read a one-line XML response from an API
- Tidy an Android layout, Maven pom.xml or .csproj file
- Check a sitemap or RSS feed by eye
- Minify XML before embedding it or sending it
How to use
- Paste your XML, or press Try an example.
- Choose the indent, or tick Minify instead.
- Copy the formatted XML or download it.
- If there's an error, fix it, or use the XML validator for a full report.
FAQ
Will formatting change my data?
It only changes the whitespace between tags. Text inside elements and attributes is kept, though whitespace-only text between tags is replaced by the new indentation.
Why do I get an error?
The XML isn't well formed. Common causes are a missing closing tag, mismatched case (<Item> closed by </item>) or a bare & that should be &.
Can I convert it to JSON?
Yes. The XML to JSON converter turns elements and attributes into JSON objects.
Related tools
- JSON FormatterFormat, validate, and beautify JSON data with syntax highlighting.
- HTML FormatterBeautify HTML code with proper indentation and formatting.
- XML EscapeEscape special XML characters for safe inclusion in XML documents.
- SQL FormatterFormat and beautify SQL queries with proper indentation.
- CSS MinifierMinify CSS code by removing whitespace and comments.
- JS MinifierMinify JavaScript code to reduce file size.