XML Formatter & Validator

Format, minify and validate XML with clear error messages — right in your browser.

How to use

  1. Paste your XML in the input field — an API response, a configuration file, an invoice, an RSS feed.
  2. Choose the indentation you prefer (2 spaces, 4 spaces or tabs) and click "Format", or click "Minify" to strip all extra whitespace into a single line.
  3. If the document is malformed, the exact line and error appear instantly; if it is valid, copy or download the clean result. Everything runs in your browser.

About this tool

XML is still everywhere in real-world systems: SOAP and legacy APIs, RSS and Atom feeds, Android and Maven configuration, SVG images and, in Brazil, every electronic invoice (NF-e) that travels between companies and the tax authority. Those documents usually arrive minified or inconsistently indented, and a single missing closing tag can break an entire integration. This tool does the two jobs you need most: it tells you immediately whether a document is well-formed, and it rewrites it with clean, consistent indentation so the structure becomes readable.

Validation uses the XML parser built into your browser — the same strict engine that powers the web platform — so the well-formedness check is the real thing, not a regex approximation. When parsing fails, the tool extracts the line number and the parser's message and shows them in a friendly format, pointing you straight at the mismatched tag, the stray ampersand or the broken attribute. Formatting is done by a purpose-built recursive serializer that walks the parsed tree and rebuilds the document: elements are indented level by level, empty elements collapse to the compact self-closing form, and elements that contain only text stay on one line for readability.

The serializer deliberately preserves what generic pretty-printers often destroy: CDATA sections keep their raw content untouched, comments and processing instructions stay where they were, attribute values are re-escaped correctly, namespace prefixes are kept intact, and the XML declaration from your original document is carried over. The "Minify" button applies the same engine in reverse, dropping ignorable whitespace to produce the smallest equivalent document — handy before embedding XML in a request body. Your files never leave the page: parsing and rewriting happen entirely on your device.

Frequently asked questions

What does "well-formed" mean in XML?

A well-formed document obeys XML's structural rules: one root element, every tag closed, attributes quoted, and special characters escaped. It is the minimum for any parser to accept the file — this tool checks exactly that, using the browser's native XML parser.

Does the validator check XSD or DTD schemas?

No. It verifies well-formedness (syntax), not conformance to a specific schema. A document can be perfectly well-formed and still be rejected by a system that expects particular elements — schema validation requires the XSD and a dedicated validator.

Will formatting change my data?

No. Only ignorable whitespace between elements is affected. Text content is preserved, CDATA sections are kept byte-for-byte, and comments, processing instructions and attributes all survive the round trip.

Why did my document fail with "entity not defined"?

XML only predefines five entities: &, <, >, " and '. HTML names like   are invalid in plain XML — replace them with numeric entities such as   or declare them in a DTD.

Does my XML leave my browser?

No. Parsing, validation, formatting and minification run 100% in JavaScript on your device. Nothing is uploaded, logged or stored — safe even for invoices and documents with sensitive data.

Related tools

Long links? Shorten them for free

Vai.la turns any URL into a short link with click statistics, QR Code and your own biolink.

Vai.la is not responsible for how the tools are used or for decisions made based on their results.