XML Formatter and Validator
This tool gives a quick browser-based check for well-formed XML and formats a small document so nested elements and attributes are easier to inspect.
Workspace
What Is the XML Formatter?
The XML Formatter formats, validates, and minifies XML (Extensible Markup Language) in your browser. Paste compact or messy XML and it returns clean, indented XML that is easy to read and check. If the XML is not well-formed, it reports the problem so you can fix tags, nesting, or quoting before using the file in an app, feed, sitemap, or configuration.
XML is a text format for structured data made of elements, attributes, and text. Unlike HTML, XML requires strict nesting: every opening tag needs a matching closing tag, tags must close in the reverse order they opened, and attribute values must be quoted.
How to Use the XML Formatter
- Paste your XML into the input box, or type it directly.
- Choose an indent size if the option is shown, for example 2 spaces or 4 spaces.
- Click Format to beautify the XML, or Minify to compress it to one line.
- Check the output. If there is an error, read the message, fix the input, and format again.
- Click Copy to copy the formatted result, or Validate if you only want to check whether the XML is well-formed.
Worked Example
Suppose you paste this minified XML:
<book><title>Dune</title><author>Frank Herbert</author><year>1965</year></book>
With 2-space indentation, Format returns:
<book> <title>Dune</title> <author>Frank Herbert</author> <year>1965</year> </book>
The data is unchanged: title is still Dune, author is still Frank Herbert, and year is still 1965. Minify reverses this and returns the original one-line version. If you paste <book><title>Dune</book>, the tool reports an error because the title element is not closed before book closes.
Limitations
- The tool checks that XML is well-formed. It does not check it against a DTD or XML Schema unless the tool explicitly says it validates against a schema.
- Very large files may be slow on low-memory devices, and extremely large pastes can hit browser input limits.
- Formatting only changes whitespace between elements. It does not change element names, attributes, or text values.
- An XML declaration such as
<?xml version="1.0" encoding="UTF-8"?>must be at the very start of the file, with no blank line or space before it. - Special characters in text must be escaped: use
&for &,<for <, and>for >.
Frequently Asked Questions
What is the difference between Format and Minify?
Format adds line breaks and indentation so XML is easy to read. Minify removes unnecessary whitespace so XML is as small as possible. Both keep the same data.
Why does my XML show a syntax error?
Common causes are a missing closing tag, tags closed in the wrong order, an unquoted attribute value, a stray < or & in text, or multiple root elements. Fix the reported position and try again.
Does formatting change my data?
No. Formatting only changes whitespace between elements. Element order, names, attributes, and text stay the same.
Can XML have more than one root element?
No. A well-formed XML document must have exactly one root element that contains all other elements. In the example above, book is the single root.
Related Tools
From the Blog
How to Split a Bill Fairly (With Tip and Tax, Without the Awkward Maths)
Quick Answer Agree the method before ordering, split the food by what each person ordered, and split tax and tip in proportion…
Read article →How to Use the Pomodoro Technique to Actually Finish Your Work
Most productivity advice tells you what to do and leaves the when to you. That is exactly where the day falls apart.…
Read article →How to Merge PDF Files Into One Document (Without Losing Pages)
You have five PDFs. Your bank wants one file. Your university wants one file. Your client wants one file. Merging them is…
Read article →