XML Formatter & Validator
Validate XML and rewrite it with the indentation you choose, or compress it onto fewer lines.
Your data stays in your browser. This tool processes your input locally and does not upload it to a server.
Input
Output
What does an XML formatter do?
An XML formatter checks that a document is well-formed and rewrites it with consistent indentation, one tag or text node per line. It makes nested structures readable. A minifier does the reverse and removes the whitespace between tags. FestivKit does both in your browser, so the XML never leaves your device.
How the formatter and validator work
Before formatting, the tool validates the input. It reports syntax errors such as unclosed tags or bad attributes with a line and column. It also rejects documents with more than one root element and named entities other than the five XML defines (&, <, >, ", ').
Formatting then places each tag and each piece of text on its own line and indents by nesting depth. You can choose 2 spaces, 4 spaces, or tabs. Declarations, comments, DOCTYPE and CDATA sections are kept as written. Attributes are never reordered or changed.
When to format and when to minify
Format XML when you read a SOAP response, a sitemap, an RSS feed, an Android layout or a config file and need to see the hierarchy. Pretty output also gives cleaner diffs in version control.
Minify when size matters or when a system expects compact input. Minifying removes whitespace between tags, so it is safe for data documents. Be careful with mixed content, where whitespace between inline elements can be meaningful.
Limits and privacy
Everything runs locally with no upload. The formatter stops with a message if nesting goes deeper than 100 levels or if the indented result would exceed 1 MB. The validator checks well-formedness only. It does not validate against an XSD or DTD schema.
Examples
Format with 2 spaces
Input
<a><b x="1">hi</b><c/></a>Output
<a>
<b x="1">
hi
</b>
<c/>
</a>Text content gets its own line, indented one level deeper than its tag.
Minify
Input
<a>
<b/>
</a>Output
<a><b/></a>Whitespace between tags is removed.
Reject two roots
Input
<a/><b/>Output
This is not valid XML. XML must have a single root element.The same message appears for formatting and minifying.
Common mistakes and edge cases
- A well-formed document is not a valid one. This tool checks syntax, not schema rules.
- Formatting adds whitespace inside elements that contain text. If your application treats whitespace as significant, compare the result carefully or minify instead.
- Entities such as or © are HTML, not XML. They are reported as undefined; use numeric references like   instead.
- XML allows only one root element. Pasting several fragments side by side fails validation.
- Attribute values must be quoted and tag names are case-sensitive: <Item> and </item> do not match.
- Very large or deeply nested files are refused (over 100 levels, or indented output above 1 MB).
How to use this tool
- Paste XML into the input editor.
- Format with 2 spaces, 4 spaces, or tabs, or minify it.
- Copy or download the XML file.
Frequently asked questions
How do I validate XML online without uploading it?
Paste the XML into the editor and press Format or Minify. The tool parses it in your browser and shows either the result or an error with the line and column of the problem. Nothing is sent to a server. Note that this checks well-formedness: matching tags, quoted attributes, one root and legal entities. It does not check the document against an XSD or DTD schema.
Why does my XML say it needs a single root element?
The XML specification requires exactly one root element that contains everything else. Input like <a/><b/> has two top-level elements, so it is not a well-formed document. Wrap the parts in one parent element, for example <items>...</items>. XML declarations, comments and processing instructions may sit outside the root.
What is the difference between formatting and minifying XML?
Formatting adds line breaks and indentation so a person can read the structure. Minifying removes whitespace between tags so the file is smaller. Both keep tag names, attributes and text content. Both run the same validation first, so a broken document is reported instead of being changed.
Does the formatter change my attributes or comments?
No. Attributes keep their order and values, and comments, CDATA sections, the XML declaration and DOCTYPE are kept as written. Only the whitespace between tokens changes, and each token moves to its own line at the correct indentation.
Why is reported as an undefined entity?
XML predefines only five entities: &, <, >, " and '. Names like come from HTML and are undefined in plain XML. Replace them with numeric character references such as  , or declare the entity in a DTD in the system that consumes the file.
References
Last reviewed