HTML Encode / Escape
Escape HTML special characters online by converting markup to character references such as <, >, &, and ". Read more
Escape HTML online
HTML encoding replaces characters that have special meaning in markup with character references. For example, <div class="x"> becomes <div class="x">, allowing the markup text to be displayed rather than interpreted as an element.
This tool escapes <, >, &, and quotation marks in the supplied text. The visible characters can later be restored with an HTML entity decoder.
How to encode HTML entities
- Paste the text or markup you want to display literally.
- Click Encode.
- Copy the escaped output into a compatible HTML text or attribute context.
- Test the complete destination document, especially when the value came from an untrusted source.
The HTML Standard defines named and numeric character references. Common examples include & for &, < for <, > for >, and " for ".
Escaping is context-dependent
Correct output encoding depends on where data is inserted. HTML text, quoted attributes, URLs, CSS, and JavaScript strings have different syntax and security rules. Escaping a value for one context does not automatically make it safe in another.
This tool is not an HTML sanitizer. It encodes the provided string but does not parse an application template, enforce a content policy, or remove dangerous URLs and script behavior from an entire document.
HTML encode FAQ
Is HTML encoding the same as URL encoding?
No. HTML character references protect markup syntax, while percent-encoding represents bytes in URLs. Use the URL Encode tool for URL components.
Will browsers display the original characters?
When the references are placed in an appropriate HTML context, the browser displays the represented characters rather than the reference text.
How do I reverse the result?
Use HTML Decode / Unescape to convert recognized named or numeric character references back to characters.