Free Online HTML Entity Encoder
Convert special characters in text into safe HTML entities.
How to use
Paste your text or HTML, or open a file into the input box.
Press Encode.
Copy the result into your page, or download it as html-encoded.txt.
Use the switch above the editor to open the HTML Entity Decoder and check it.
Why use this tool
Five characters
& becomes &, < becomes <, > becomes >, the double quote becomes " and the single quote becomes '.
Nothing else changes
Line breaks, spacing and other characters stay exactly where they were.
Works for attributes
Both kinds of quote are encoded, so the result can sit inside a quoted attribute value.
About this tool
HTML Entity Encoder replaces the five characters that have a special meaning in HTML with entities: the ampersand, the less-than sign, the greater-than sign, the double quote and the single quote. After encoding, a browser shows your text as it is written instead of reading it as tags. Use it to put code samples in a blog post or documentation, to place text inside an attribute, or to check what your own escaping code should produce. All other characters, including emoji and accented letters, are left unchanged. The page opens with an example already encoded.
Frequently asked questions
When text must appear on a page as text, such as a code sample or a comment typed by a visitor.
No. It covers text between tags and inside quoted attributes. Text placed in a script, a style, a link address or an unquoted attribute needs other handling, and your framework's escaping is usually the safer choice.
The ampersand in each entity is encoded again, so the entity itself will show on the page. Decode first if you do not want that.
No. Only the five characters above are replaced. A page saved as UTF-8 can show the others directly.
That is the purpose of encoding. If you want the tags to work, use the original HTML.