XMLformatter
Paste or type XML, then click Format
Runs fully in your browser — no data is uploaded or stored.
Input
Output
</>
formatted XML will appear here

XML Formatter / Validator — Format, Validate & Minify XML Online

Runs in your browser. No upload, no account.

Updated May 17, 2026
Share & Support

What's included

Features

Format (pretty-print) XML — apply configurable indentation and newlines so deeply nested structures are easy to read and navigate
Minify XML — strip all inter-tag whitespace to produce the smallest valid XML representation for API payloads and config storage; convert between formats with the YAML to JSON converter or CSV to JSON converter
Validate XML online — check well-formedness with precise error messages showing line and column numbers for mismatched or unclosed tags — the XML counterpart to the JSON formatter
Syntax highlighting — color-code element names, attribute names, attribute values, comments, CDATA sections, and processing instructions
CDATA section support — CDATA blocks are preserved exactly in formatting and minification without modifying the raw character data
XML comment preservation — comments are kept and indented at the correct level in formatted output
Configurable indentation — choose 2 spaces, 4 spaces, or tabs to match your project or editor style guide
Copy and Download — copy the formatted or minified output to clipboard, or download as a .xml file ready for use
Sample XML button — load a ready-made example document with nested elements, attributes, and a CDATA section to explore the tool
100% private — runs fully in your browser, no data is uploaded or stored anywhere
Namespace and processing instruction support — handles xmlns declarations, namespace-qualified tags, and <?xml?> processing instructions
Responsive two-panel layout — input on the left, syntax-highlighted output on the right; stacks vertically on mobile

About this tool

XML Formatter, Validator & Minifier — Pretty-Print, Validate, and Compress XML in Your Browser

You got a wall of minified XML back from a SOAP API, a configuration file exported from a legacy system, or an RSS feed — and you can not read it. Or you wrote an XML document by hand and need to know if the tags are balanced before sending it to a parser. Or you need to compress a verbose config file before embedding it in an environment variable. This XML formatter handles all of it: paste your XML, click Format, and the tool instantly pretty-prints it with syntax highlighting, indentation, and correct nesting — right in your browser.

Format (pretty-print) XML adds indentation and newlines so the hierarchical structure is immediately visible. Each nested child element is indented one level deeper than its parent. You can choose 2-space indentation (the most common default), 4-space indentation (common in Java and XML Schema projects), or tab indentation to match your editor settings. XML comments are preserved at the correct indentation level. CDATA sections are kept intact without modifying the raw character data inside them. Processing instructions like the XML declaration are placed at the top of the formatted output exactly as written.

Validate XML checks your document for well-formedness errors — the most common cause of XML parse failures. The validator checks for unclosed tags, mismatched opening and closing tag names, multiple root elements, unclosed comments, and malformed CDATA sections. When an error is found, the error banner shows a precise message with the line and column number so you can jump directly to the problem. This catches the class of errors that make XML parsers throw with an unhelpful "unexpected token" message pointing to the end of the file rather than the actual problem location.

Minify XML strips all inter-tag whitespace — spaces, tabs, and newlines — leaving only the markup and text content. A typical formatted XML configuration file that is 6KB pretty-printed can become 1–2KB minified. Use the minified output in API request bodies, HTTP headers, environment variables, CloudFormation templates, or any field where compact XML is expected. The minifier preserves CDATA sections without altering their contents, since CDATA whitespace is semantically significant.

Syntax highlighting colors different parts of the XML structure so you can scan it quickly: element names in blue, attribute names in green, attribute values in yellow, comments in gray italic, CDATA sections in purple, and processing instructions in pink. This makes it easy to spot a misspelled attribute name, a missing closing quote, or an incorrect element name at a glance.

All processing runs entirely in your browser. No server receives your XML. No data is uploaded, logged, or stored. You can safely paste XML that contains database credentials, API keys, private configuration, financial records, or patient data — it never leaves your machine. There is no account required, no rate limits, and no install.

Step by step

How to Use

  1. 1
    Paste your XMLClick the input panel on the left and paste your XML. This can be minified XML from an API response, a hand-written document with uncertain structure, a configuration file, or any XML string you want to inspect.
  2. 2
    Click Format to pretty-printClick the Format button to apply indentation and newlines. Use the indent selector to choose 2 spaces, 4 spaces, or tabs. The formatted XML appears in the right panel with syntax highlighting. If your XML has a well-formedness error, a red status banner shows the error message and line number.
  3. 3
    Validate to check for errorsClick Validate to check your XML for well-formedness issues without reformatting the output. The status bar shows either "Valid XML" in green or a detailed error message in red with the approximate line and column number where the problem was detected.
  4. 4
    Minify for compact outputClick Minify to strip all whitespace between tags. This produces the smallest possible XML string. CDATA content is preserved unmodified. Use the minified output in API bodies, environment variables, or any field that expects compact XML.
  5. 5
    Copy or Download the resultClick Copy to copy the formatted or minified output to your clipboard, ready to paste into your code editor, terminal, or HTTP client. Click Download to save the result as formatted.xml on your machine.

Real-world uses

Common Use Cases

{}
Debug a SOAP API or RSS feed response
SOAP web services and RSS feeds return XML that is compact or difficult to read inline. Paste the response here and click Format to see the element hierarchy clearly with syntax highlighting. The color-coded output makes it easy to find missing fields, extra elements, or unexpected attribute values during integration work — without installing Postman or a dedicated XML editor.
Validate hand-written XML before deployment
Writing an XML configuration file, XSLT stylesheet, or Ant build script by hand is error-prone. Paste the file and click Validate before deploying. The validator reports any unclosed tags, mismatched tag names, or multiple root elements with the line and column number so you can fix problems locally rather than diagnosing a cryptic parse error from a remote server or build system.
Minify XML for API requests and environment variables
Before embedding XML in a curl command, an HTTP request body, a CloudFormation template parameter, or a Kubernetes ConfigMap — minify it. The Minify button strips all inter-tag whitespace in one click. CDATA content is preserved without modification. The result is copy-ready for any field that expects compact XML without line breaks.
Read a Maven pom.xml or Spring configuration file
Maven pom.xml files and Spring applicationContext.xml files are often several hundred lines long and deeply nested. Paste the file, adjust the indent selector to 2 or 4 spaces, and click Format to normalize inconsistent indentation from different contributors. The formatted version is much easier to navigate and edit.
Format XML Schema (XSD) and WSDL files
XSD schema files and WSDL service definitions use deeply nested XML structures with namespace declarations. Paste the XSD or WSDL and format it to see the type hierarchy and element constraints clearly. Syntax highlighting distinguishes element names from attribute names and values so you can read complex schema structures at a glance.
Clean up exported configuration files
Many tools export XML configuration — IntelliJ run configurations, Android resource files, SVG exports from Figma, Office Open XML fragments. Exported files often have inconsistent or missing indentation. Paste and format to normalize the structure, then copy back into your project. The output uses your chosen indentation style and consistent newlines throughout.

Got questions?

Frequently Asked Questions

Paste your XML into the input panel on the left and click Format. The tool instantly applies indentation, line breaks, and syntax highlighting so you can read the nested structure clearly. Use the indent selector in the toolbar to choose 2 spaces, 4 spaces, or tab indentation depending on your project style. Tags are highlighted in blue, attribute names in green, attribute values in yellow, and comments in gray. The output is ready to copy or download as a .xml file.

Paste your XML and click Validate. If the XML is invalid, a red error banner shows the exact problem along with the line and column number — for example "Mismatched tag: expected </book> but found </books> (line 12, col 3)". Common errors caught include unclosed tags, mismatched opening and closing tag names, multiple root elements, unclosed processing instructions, and malformed CDATA sections. Fixing the shown line and column is much faster than scanning the whole document.

Format (pretty-print) adds indentation and line breaks to make XML human-readable. Each nested element is indented according to its depth, making the hierarchy immediately visible. Minify does the opposite — it strips all whitespace between tags to produce the most compact single-line representation. Use Format when you need to read, debug, or edit XML. Use Minify when you need to reduce payload size for API requests, configuration storage, or any place where whitespace wastes bytes.

Yes. CDATA sections (wrapped in <![CDATA[ ... ]]>) are fully preserved in both formatted and minified output. Their content is never modified — whitespace inside CDATA is kept exactly as written since CDATA is treated as raw character data. XML comments (<!-- comment -->) are also preserved and formatted at the correct indentation level. Both CDATA and comments receive distinct syntax highlighting colors in the output panel so they stand out visually from regular element content.

Yes. Namespace declarations (xmlns:prefix="uri") are treated as regular attributes and highlighted accordingly. Namespace-qualified element names like <xsi:element> and attribute names like xsi:type are fully supported. Processing instructions like <?xml version="1.0" encoding="UTF-8"?> and <?xml-stylesheet type="text/xsl" href="style.xsl"?> are preserved and displayed in pink syntax highlighting to distinguish them from regular elements.

Yes, completely private. All XML parsing, formatting, validation, and minification runs entirely inside your browser using JavaScript — nothing is ever sent to any server. You can safely paste XML that contains API credentials, configuration secrets, user data, financial records, or any other sensitive content. When you close or refresh the tab, all pasted content is gone permanently. There are no analytics, no logging, and no third-party services that process your input.

Paste your XML and click Minify. The tool strips all whitespace between tags — spaces, tabs, newlines — leaving only the tag markup and text content. The result is the smallest valid XML representation. A typical configuration file that is 5KB when formatted can shrink to 1–2KB minified. Use minified XML in API request bodies, embedded configuration strings, environment variables, or anywhere byte count matters. The minified output preserves CDATA content and comment nodes exactly.

The validator catches the most common well-formedness errors in XML: unclosed tags (an opening tag with no matching closing tag), mismatched tag names (opening and closing tags with different names), multiple root elements (XML requires exactly one root), unclosed comments (<!-- without -->), unclosed CDATA sections (<![CDATA[ without ]]>), and unclosed processing instructions (<? without ?>). For each error the validator reports the approximate line and column number so you can jump directly to the problem.