XML Formatter & Validator
Paste XML to check that it is well formed, then pretty print it with indents or minify it. Errors show the line and column to fix.
Este contenido está en inglés.
Ejemplos resueltos
Pretty printing an order
<order><item id='1'>Pen</item></order>
<order> <item id='1'>Pen</item> </order>
Each element sits on its own line and the document is checked first, so a valid file is laid out without changing its content.
Finding a mismatched tag
<order><item>Pen</order>
Error: the closing </order> tag does not match the open <item> tag on line 1. Nothing is changed.
The tool reports the first problem and its position so you can fix the source before formatting again.
Sobre XML Formatter & Validator
XML is strict. A single missing closing tag or a stray ampersand makes the whole document unreadable to the program that loads it. This tool checks your XML first and, if something is wrong, tells you the line and column of the first problem along with a plain description, such as a tag that does not match the one before it. Fix that line and the check runs again as you type, so you can work through problems one at a time.
Once the document is well formed you can pretty print it, which puts each element on its own line and indents child elements below their parent, or minify it by removing the whitespace between tags. Comments can be kept or dropped. Elements that mix text with other tags are left as written so no meaningful spaces are lost, and CDATA sections, processing instructions and declarations are preserved. Element, attribute and depth counts are shown for a quick overview. This makes it handy for feeds, sitemaps, SVG files and configuration data.
Cómo usar XML Formatter & Validator
- Paste your XML into the input box, or open an .xml file.
- Read the message to see whether the XML is well formed.
- Choose Pretty print or Minify, then set the indent size and comment option.
- Copy the result or download it.
Usos habituales
- Finding the exact line of a mistake in a configuration file
- Reading a feed or an API response that arrives on one line
- Shrinking XML data before sending it
- Tidying an SVG or sitemap file by hand
Preguntas frecuentes
How do I check if my XML is valid?
Paste it into the input box. If it is well formed you see a confirmation with the number of elements and attributes. If not, you see the line and column of the first problem and a short description, and no output is produced until it is fixed.
What does well formed mean?
A well formed document has exactly one root element, every opening tag has a matching closing tag in the right order, attribute values are in quotes, and special characters such as & and < are written as entities. It does not mean the content matches a particular schema.
Why do I get an error about an ampersand?
In XML an ampersand starts an entity, so a bare & in text is not allowed. Write it as & instead. The same goes for a less-than sign, which should be < inside text. Only five entities are built in, so other named ones such as need a numeric form.
Does pretty printing change my data?
Whitespace between elements is added or removed, and spaces at the start and end of a plain text value are trimmed. Elements that contain both text and tags are left exactly as written so meaningful spaces are not lost. Attribute values and the text inside are untouched.
Can I minify XML?
Yes. Choose Minify and the whitespace between tags is removed, leaving one compact line. Text values are not trimmed, so the data stays as written. You can keep or remove comments, and the message shows the number of bytes saved.