XML Formatter

Paste XML and get it properly indented, or minified, with well-formedness checked as you type. When something is wrong you get the line and column and a specific reason — a close tag that matches nothing, tags that overlap instead of nesting, an element never closed — rather than the localised paragraph a browser's own parser produces, which differs between browsers and often carries no usable position at all. Three details are handled that trip up regular-expression formatters: a greater-than sign inside a quoted attribute does not end the tag, markup inside a comment is not markup, and CDATA is kept verbatim because holding text that would otherwise be parsed is its entire purpose. Whitespace inside xml:space="preserve", and inside pre, script, style and textarea, is left exactly as written — reflowing it would change what the document means. Drop a file or paste; nothing is uploaded.

What makes XML malformed

WrittenProblem
<a><b></a><b> is never closed
<b><i></b></i>Tags overlap rather than nest
</a>Closes something never opened
<a href=x>Attribute value must be quoted
<br>Fine in HTML, needs <br/> in strict XML
a < bA bare < must be written &lt;

When to use it

  1. Make a one-line XML response readable.
  2. Find why a config or feed file is being rejected.
  3. Check an RSS or sitemap file is well-formed.
  4. Minify XML before embedding it somewhere.
  5. Tidy an SVG or plist by hand.

How to Use

  1. Paste your XML or drop a file.
  2. Choose indentation, or switch to minify.
  3. Fix anything reported at the line and column given, then copy the result.

Features

  1. Indent with spaces or tabs, any width
  2. Minify while keeping meaningful whitespace
  3. Well-formedness errors with exact line and column
  4. Specific messages for overlap, orphan and unclosed tags
  5. CDATA and comments never interpreted
  6. Greater-than inside attributes handled correctly
  7. xml:space="preserve" and pre/script/style respected
  8. Drop a file or paste, 100% client-side

FAQs

Is my XML uploaded?

No. It is parsed and formatted in your browser. XML files routinely carry configuration and credentials, so this is not incidental.

Why not use the browser's own XML parser?

Because its error reporting is unusable for this. A failure comes back as a localised sentence inside a parsererror element, worded differently in each engine and frequently with no position. Scanning the document directly gives the same line and column everywhere.

What counts as not well-formed?

Most often a tag that is never closed, a close tag that matches nothing, or tags that overlap rather than nest — writing <b><i></b></i> instead of <b><i></i></b>. Attribute values must also be quoted, which HTML forgives and XML does not.

Will it reformat the contents of my CDATA or <pre>?

No. CDATA is kept exactly as written, as is anything inside xml:space="preserve", pre, script, style or textarea. Reformatting those would change what the document says rather than just how it looks.

Can it format HTML too?

Partly. Void elements like <br> and <img> are understood so they are not reported as unclosed, but HTML has its own rules about optional closing tags. For HTML, use the dedicated HTML formatter.

Does it validate against a schema?

No. It checks well-formedness — that the structure is valid XML — not validity against a DTD or XSD, which is a separate and much larger question requiring the schema itself.

Technical Details

Formatting is done by a purpose-written tokenizer rather than by DOMParser and XMLSerializer, for the same reason the JSON tools avoid the engine's parse messages: the browser reports a malformed document as a localised sentence inside a parsererror element, with wording that differs per engine and no dependable position, so a tool built on it points at the right place in one browser and gives an unhelpful paragraph in another. Here the document is scanned directly and the first structural problem is reported with a line and column — a close tag that matches nothing, a close tag that overlaps rather than nests, an unclosed element, or a tag missing its bracket — each named specifically rather than as a generic failure. Three things the tokenizer has to get right, all of which a naive regular expression gets wrong. A greater-than sign inside a quoted attribute value does not end the tag, so quoting is tracked while scanning. Markup inside a comment is not markup, so a less-than inside one must not open an element. And CDATA exists precisely to hold text that would otherwise be parsed, so it is captured whole and never interpreted. Indentation is then structural, with one concession that matters: whitespace inside an element carrying xml:space="preserve", or inside pre, script, style or textarea, is emitted exactly as written. Reflowing those silently changes what the document says, which is the difference between formatting and corruption. Short text between an open and close tag stays on the line rather than being split across three, because that is how a person would write it. Minifying collapses the whitespace that is only formatting while keeping whitespace that separates words, and leaves preserved regions untouched.

Developer Tools

Developer Tools

  • cURL Command Builder
  • cURL to Code
  • HTTP Status Codes
  • Subnet Calculator
  • IP & MAC Validator
  • URL Parser
  • URL Query Builder
  • Base Encoding Converter