xmltoolskit.org
XML utilities, in the browser
Say hi →

XML Repair — fix broken XML

updated 20 August 2026 · unclosed tags · bare ampersands · HTML entities

Paste XML that will not parse and get a version that does — with a list of exactly what was changed. It closes unclosed tags, escapes bare ampersands, quotes unquoted attribute values, converts HTML-only entities, and wraps a document that has more than one root.

repair
Drop a .xml file here, or

      
ready

XML Repair

A parser tells you where a document breaks; this tries to fix it. Each repair is a targeted rewrite of a specific, common breakage, and the report below the panes lists every change made plus whether the result now parses. Nothing is guessed silently.

How to use it

  1. Paste the broken XML into the left pane, or drop the file on it.
  2. Leave all the repairs on for a first pass — the report tells you what each one did.
  3. If a repair changed something you did not want changed, untick it and run again.
  4. Read the last line of the report: it says whether the result is now well-formed.

What each repair does

What it will not fix

Repairs are textual and conservative, so some breakage is out of scope: a truncated file with the second half missing, a mis-encoded document (Latin-1 bytes labelled UTF-8), a mismatched tag whose intent is genuinely ambiguous, or an unescaped < inside text that could equally be the start of a tag.

When the report's last line still says the document is not well-formed, it also carries the parser's message — that is your next clue.

Check the result before trusting it

Automatic repair changes your data. Closing tags in reverse order, in particular, is a guess about nesting that is right for a truncated document and wrong for a genuinely mis-nested one. Diff the output against the original — the XML diff is the quickest way — before it goes anywhere important.

FAQ

Will it fix mismatched tags like <b><i></b></i>?

It will make the document parse, by closing <i> before </b> and dropping the now-stray </i>. Whether that is the nesting you meant is a judgement only you can make — check the report and the diff.

Why is my &amp;nbsp; now a number?

XML has no &nbsp;. It is converted to &#160;, which every parser understands and which renders identically. Untick fix HTML entities if you would rather see the parse error.

What about an unescaped less-than sign in text?

That is deliberately not repaired. A bare < in text is indistinguishable from the start of a tag, and guessing wrong would corrupt the document. Escape those by hand — the escape tool helps.

Does it preserve comments and CDATA?

Yes. Comments, CDATA sections, processing instructions and the doctype are passed through untouched; only the specific breakages listed above are rewritten.

Is the file uploaded anywhere?

No. Every repair runs in your browser, so a broken export full of customer data stays on your machine.

Related tools

Privacy

100% client-side. Repairs are textual rewrites performed in the page. See the privacy policy.