01 / Example
Example
<p class="greeting">Hello & welcome</p><p class="greeting">Hello & welcome</p>Text & code / MULTIVERTO
Escape text for HTML by turning &, <, > and quotes into entities. Useful when showing code as text.
Apply each text tool to the previous result. Text workflows ↗
Only the recipe name and tool order are saved in this browser. Your input and results are never saved.
01 / Example
<p class="greeting">Hello & welcome</p><p class="greeting">Hello & welcome</p>02 / Guide
To display the literal snippet <b>A&B</b> in an HTML text node, encode it as <b>A&B</b>. The browser then shows the angle brackets and ampersand instead of creating a bold element. This converter also escapes quotation marks and apostrophes, but that does not make arbitrary strings safe in every context. A URL, CSS declaration, JavaScript string or unquoted attribute has different rules. Insert user text with a safe text API when one is available.
Do not encode a whole trusted HTML document when you intend its tags to render: you would see tag characters instead of formatted content. For user-submitted comments, prefer assigning textContent or a framework’s safe text binding; those APIs manage the correct context. If the value will go into an href, a style rule or a JavaScript literal, choose an encoder or safe API for that specific destination rather than reusing HTML text escaping.
HTML reserves characters such as the ampersand and angle brackets for markup. Character references let a document represent those characters as data: for example, an ampersand can be written as &, while a less-than sign can be written as <. Browsers interpret references when parsing HTML. Named references and numeric references are both possible, but a reference is only meaningful in the context in which an HTML parser consumes it. Seeing entity-like text in a plain text file does not mean the file itself has been rendered as HTML.
When preparing documentation that displays markup literally, inspect the source HTML after inserting the encoded result. A single parsing pass should display the intended angle brackets, not create an element. If a content editor encodes the value again, readers may see the entity names instead of the symbols. Fix the insertion path rather than decoding arbitrary input in the browser. A text node is the intended destination for this result; an attribute, script or style block has different escaping rules. Recheck the rendered page with an ampersand in the example because it is easy to mistake a pre-existing reference for literal source text. When a page should show a literal tag such as <strong> rather than interpret it, encode that text before placing it in an HTML text node. Compare the displayed page with the source characters, including ampersands and quotes. Attribute values, URLs, CSS and JavaScript require their own contextual handling; this result is not an HTML sanitizer. The page example turns “<p class="greeting">Hello & welcome</p>” into “<p class="greeting">Hello & welcome</p>”.
Explore guides