Code samples in a blog post, a product name with an ampersand in an RSS feed, or a scraped string full of " all need the same fix: replace characters with character references, or turn them back. This converter does both directions under HTML or XML rules. The difference matters: XML knows only five named entities, so or é break an XML parser unless written as numbers, while HTML accepts over two thousand names. The table lists every reference touched, with its character, Unicode code point and how many times it appeared. One limit: decoding covers the common named references (Latin accents, punctuation, currency, arrows, Greek letters) plus every numeric form; rare HTML names are left as typed and listed in a warning.
How to use it
Paste or open the text
Paste markup or encoded text, or open a .html, .xml or .txt file; it is read in your browser.
Pick Encode or Decode
Encode escapes characters into references; Decode turns references back into characters.
Choose HTML or XML rules
XML uses ' and only five names; HTML uses ' for the apostrophe and knows many more names.
Check the reference table
Each row shows one reference, its character and code point; copy a single reference from its row.
Encoded 2 references using the XML 1.0 predefined set.
Length went from 10 to 18 characters.
XML has its own name for the apostrophe, ', which is safe inside a single-quoted attribute.
How it is calculated
reference = &name; or &#decimal; or &#xhex; ⇔ one Unicode code point (WHATWG named references, XML 1.0 §4.6)
&name;
a named reference, such as & for U+0026
&#decimal; / &#xhex;
the code point written in base 10 or base 16
Encoding replaces &, <, > and the double quote with &, <, > and ". The apostrophe becomes ' under XML rules and ' under HTML, because ' was missing from HTML 4. With the non-ASCII option, characters above code 126 become a named HTML reference when one exists, otherwise a decimal one. Decoding reads numeric references in any range from 1 to 10FFFF except surrogates, and named ones from the selected set; anything else stays untouched so nothing is silently lost.
In a browser, set the string as the innerHTML of a textarea element and read its value, or use DOMParser and read textContent. Both run the browser's own HTML parser, so every named reference works. In Node there is no DOM, so a package such as 'he' or 'entities' does the job. To check a single string by hand, paste it here with Decode selected.
The JDK has no built-in method. Apache Commons Text provides StringEscapeUtils.escapeHtml4 and escapeXml11, and the OWASP Java Encoder provides Encode.forHtml for output placed in a page. For a quick manual check, encode the same text here and compare: a < should come out as < and an ampersand as &.
How do I decode XML entities in Golang?
encoding/xml decodes the five predefined entities and numeric references automatically when it parses a document. For a loose string, html.UnescapeString from the standard library also handles them, plus HTML names. To escape, xml.EscapeText writes <, >, &, " and ' to a writer.
How do I decode XML entities in Swift?
Foundation's XMLParser resolves the predefined entities and numeric references while it parses, so element text arrives already decoded. For a plain string outside a document, Swift has no one-line call; you replace the five names and numeric forms yourself or use NSAttributedString with the HTML document type on Apple platforms.
Can I decode entities in a whole XML file?
Yes. Use the open-file button to load a .xml, .svg or .html file; it is read locally and never uploaded. Pick Decode and XML rules, and the result box shows the file with references replaced. Any name XML does not define, such as , is kept and reported in a warning.
Is an HTML decoder the same as a URL decoder?
No. URLs use percent-encoding, where a space is %20 and an ampersand is %26. HTML uses references like & and . A link inside an href attribute can need both: percent-encoding inside the URL, then & for each ampersand separating query parameters in the markup.
Cite this tool
Using this tool in an assignment, article or report? Copy a citation, or a link for your website.
Link<a href="https://directory.milunir.com/developer-tools/encoders-decoders/html-and-xml-entity-encoder-decoder/">HTML and XML Entity Encoder Decoder – Tools Directory</a>