XML

Pretty-print and validate XML — runs entirely in your browser.

Reset
Copy
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <book id="bk101">
    <author>Alice</author>
    <title>Renderhub Reference</title>
    <year>2026</year>
  </book>
  <book id="bk102">
    <author>Bob</author>
    <title>SSG Patterns</title>
    <year>2025</year>
  </book>
</catalog>

Tips

  • Pretty-print rewrites the document with consistent indentation.
  • Validation runs in your browser via DOMParser.

What this XML tool does

XML is still the wire format for many enterprise systems, document standards (OOXML, SVG, XHTML), and configuration files in older Java and .NET projects. This page pretty-prints and validates XML in your browser, so you can paste an API response or an export file and confirm it is well-formed before trying to parse it further.

Well-formed vs valid

These two words are not interchangeable. Well-formed means the XML follows the basic syntactic rules — every opening tag has a matching closing tag, attributes are quoted, characters are properly escaped. Valid additionally means the document conforms to a specific schema (DTD, XSD, RELAX NG). This tool checks well-formedness only; schema validation requires the schema document itself and is best done in the toolchain that owns it.

What to watch for

  • Unescaped ampersands. A raw & inside element text or an attribute value is the single most common cause of "not well-formed" errors. Replace it with &amp;.
  • Namespaces. Elements like <ns:tag> need a matching xmlns:ns="..." declaration somewhere on an ancestor element.
  • Mixed BOMs and declarations. An <?xml ?> declaration must be the very first thing in the document — no whitespace or BOM before it.

Pretty-printing

Reformatting compacted XML makes diffs readable, especially when the original was a single long line produced by a generator. The pretty-printed output here keeps element ordering exactly as the parser saw it, so it is safe to diff against the source.