XML Formatter / Validator — Format, Validate & Minify XML Online
Runs in your browser. No upload, no account.
What's included
Features
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
- 1Paste 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.
- 2Click 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.
- 3Validate 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.
- 4Minify 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.
- 5Copy 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
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.