XML Formatter

Paste XML to pretty-print or minify it. Choose your indent width while preserving attributes, text, and CDATA.

Last updated: 2026/10/16 Developer Feedback & bug reports
XML Input
Result

How to Use

1

Paste XML

Paste or type your XML into the input field. You can also load an example with the Sample button.

2

Choose Indent

Select your preferred indent width: 2 spaces, 4 spaces, or a tab.

3

Format or Minify

Use Format (Pretty) for readability or Minify to compact it onto a single line.

4

Copy the Result

Copy the output with one click using the Copy button.

About the XML Formatter

A web tool that pretty-prints XML (Extensible Markup Language) into a readable, indented form, or minifies it by removing extra whitespace and line breaks. It parses your XML with the browser's built-in XML parser, preserving attributes, text, and CDATA sections. If the XML has syntax errors, it falls back to a line-based format and shows the error. All processing happens in your browser and your XML is never sent to any server.

Features

  • Format & MinifyPretty-print for readability or minify to reduce size. Pick the mode that fits your task.
  • Selectable IndentChoose 2 spaces, 4 spaces, or a tab to match your team's coding style.
  • Preserves Attributes & CDATAKeeps attribute values, text, CDATA, and comments intact, with proper quote escaping.
  • Privacy ProtectedAll processing happens in your browser. Your XML is never sent to servers.

Use Cases

  • Make API responses and SOAP messages readable
  • Inspect RSS/Atom feeds and sitemap.xml
  • Format config files (pom.xml, web.config, AndroidManifest.xml, etc.)
  • Expand minified XML to debug and diff
  • Minify XML before delivery to reduce file size

FAQ

Is the XML Formatter free to use?
Yes, it is completely free. No registration is required, and there are no usage limits. Just open the page and start using it.
What is the difference between Pretty and Minify?
Pretty adds line breaks and indentation to make the hierarchy easy to read. Minify removes unnecessary whitespace and line breaks between elements to compact the XML onto one line and reduce file size. Use Pretty for debugging and Minify for delivery.
Can it format XML that has syntax errors?
Even if the XML cannot be fully parsed, the tool applies a line-based fallback format (a line break and indent per tag) and shows the error. For accurate formatting, valid XML is recommended.
Are attributes, CDATA, and non-English text preserved?
Yes. Attribute values, text content, CDATA sections, comments, and multibyte characters such as Japanese are preserved. Special characters like quotes inside attribute values are escaped properly so the output stays valid XML.
Is my XML sent to a server? Is it safe?
No, your XML is never sent to or stored on any server. All processing happens locally in your browser (JavaScript). Because there are no external API calls or server communication, you can safely process XML that contains confidential or personal information.