XML Formatter

Pretty-print messy XML with clean indentation

XML Input

Formatted

Free Online Tool

XML Formatter — Complete Guide & Instructions

MakeCard XML Formatter takes compressed, single-line or badly indented XML and renders it with clean two-space indentation so structure is obvious at a glance. It parses the document with the browser DOMParser first — malformed XML is rejected with a clear error instead of producing garbage output. Attributes, nested elements, mixed text and self-closing tags are all preserved faithfully, making it ideal for debugging SOAP payloads, sitemaps, config files and API responses.

How to Use XML Formatter

  1. 1 Paste your XML into the "XML Input" box — or press "Sample" to see a demo.
  2. 2 Click "Format XML" to parse and re-indent the document.
  3. 3 If the XML is malformed, an error appears — fix the markup and format again.
  4. 4 Review the indented result in the "Formatted" panel, scrollable for long documents.
  5. 5 Click "Copy" to copy the formatted XML to your clipboard.

Key Features & Capabilities

  • Consistent two-space indentation for every nesting level.
  • Validates first — malformed XML produces an error, not bad output.
  • Preserves attributes on every element exactly as written.
  • Self-closing empty tags render as <tag/> cleanly.
  • Mixed text content is kept on its own indented line.
  • Scrollable output panel with one-click copy.

Supported Formats & Specifications

Parameter Specification
Indentation 2 spaces per nesting level
Parser Browser DOMParser — validates before formatting
Preserves Attributes, text nodes, nested elements, self-closing tags
Output Scrollable formatted block + copy
Extras One-click sample XML

Practical Everyday Use Cases

  • Reading a minified SOAP or REST XML response during API debugging.
  • Cleaning up sitemap.xml or AndroidManifest.xml before editing.
  • Formatting config files like pom.xml or .csproj for review.
  • Re-indenting XML exported from tools that strip whitespace.
  • Preparing readable XML snippets for documentation.

Pro Tips for Best Results

  • Format before diffing two XML files — consistent indentation makes real differences stand out.
  • Whitespace inside mixed-content elements is trimmed to keep output clean — avoid reformatting whitespace-sensitive markup.
  • Use the Sample button to verify the style matches your project's conventions.
  • Validate first with the XML Validator if a large document keeps failing — it pinpoints the error.

Common Problems & Solutions

The input must be well-formed — check for unclosed tags, stray & characters (use &amp;), or multiple root elements.

The formatter uses a fixed 2-space style — re-apply your editor's formatter after pasting if your project uses tabs or 4 spaces.

The formatter renders from the root element — re-add an XML declaration line at the top if your file needs it.

Privacy & Security

100% Client-Side Execution

Formatting is done locally by the browser DOMParser — your XML is never uploaded, transmitted or stored anywhere.

No server uploads No data logging Safe for personal documents
FAQ Section

Frequently Asked Questions

Everything you need to know about using XML Formatter

Paste the XML above and press "Format XML" — it is validated and re-emitted with clean two-space indentation you can copy instantly.

No content changes — tags, attributes and text are preserved. Only inter-element whitespace is normalised, which does not affect how parsers read the document.

Because it is not well-formed: common causes are unescaped & or < characters, mismatched closing tags, or more than one root element. Fix those and format again.

This tool expands XML for readability; removing the newlines and indentation from the output effectively minifies it back if needed.

Related FreeToolsBazaar Tools

Ready to Use XML Formatter?

100% free, browser-based, and private. No installation, registration, or file upload to external servers required.

Start Using XML Formatter