XML Encoding Fixer
Repair mojibake, remove a BOM, normalise line endings and make the encoding declaration match the text.
What is Encoding Fixer?
An encoding repair tool for XML and other text. It targets the four problems that produce the same symptom — garbled accents in a document that opens fine: a mis-decoded file, a BOM, mixed line endings and a declaration that disagrees with the content.
How it works
The text is inspected for the byte pairs that only appear when UTF-8 was read as Windows-1252 or Latin-1, for a leading BOM, for each kind of line ending, and for the control characters XML forbids. Repair is applied only when it genuinely improves the text: the candidate is re-checked and kept only if the mojibake count drops. The declaration is rewritten to an encoding you choose, validated against the names XML recognises.
- Paste the document. Drop in XML, a schema, a feed or an XPath expression. Everything is parsed in the page: no upload, no server round trip, and the tools keep working with the network switched off.
- Set the options that match your document. Indent unit, whether to keep comments, which dialect, which output method. The defaults are the safe ones — nothing that changes meaning is enabled for you.
- Read the result, then copy or download it. Results appear as you type, copy straight to the clipboard, and download with a sensible filename (.xml, .xsd, .csv). Reset returns every field to its default.
Examples
A minified document from an API response
Paste one line of XML and the Formatter indents it, wraps long start tags one attribute per line and normalises empty elements — without touching text inside mixed content.
An XPath that works in Chrome and not in your servlet
The XPath Tester evaluates against a real tree and reports the axis or function it cannot support, instead of returning zero nodes and letting you guess why.
A document that will not parse
The Validator gives line and column for every mismatched tag, stray ampersand and duplicate attribute, with the reason in words: which open element was expected, which was found.
A schema that only half matches your data
The XSD Validator marks each violation with the path of the offending node, and the Schema Generator goes the other way — inferring a starting-point XSD from real documents.
Common mistakes
Assuming a pretty-printer cannot change meaning
Whitespace between elements is often insignificant, but inside mixed content it is not: `<p>Hello <b>world</b></p>` must stay on one line. Formatting here re-indents element-only content and leaves mixed content alone.
Treating a validation pass as proof of interoperability
The DTD and XSD validators implement honest subsets. A document reported valid here can still be rejected by a full validator that understands identity constraints, substitution groups or XSD 1.1 assertions — each page lists what it does not cover.
Reading the whole document because the parser did
A DOCTYPE is not inert. If your parser resolves external entities, pasting an untrusted document is enough to read a file or call an internal URL. The XXE Risk Checker shows what a document asks for; the fix is in the parser configuration.
Forgetting that attributes and elements are not interchangeable
`<id>1</id>` and `id="1"` mean different things to every schema and every XPath. When converting to CSV or YAML the distinction is preserved (`@id`), because flattening it away is the change that costs an afternoon later.
Frequently asked questions
Why did the tool refuse to fix some characters?
Because there is nothing left to recover. A U+FFFD replacement character means the original bytes were already lost before the text got here — usually when the file was decoded incorrectly on read. Re-export the file from its source; no tool can reverse that loss.
What exactly is mojibake?
UTF-8 bytes decoded as if they were a single-byte encoding. `é` is two bytes in UTF-8, and read as Windows-1252 they become `é`. The tool translates each character back to the byte it came from and decodes the result as UTF-8 — which is why `café` becomes `café`.
Why remove the BOM?
XML allows a UTF-8 byte-order mark and most parsers handle it, but it survives inside the first text node of some readers, breaks equality comparisons and invalidates XML signature verification. It is safe to remove from a UTF-8 document, and the tool only offers it in that case.