Swelıty
Tools for everyone

Free Online HTML Entity Encoder

Convert special characters in text into safe HTML entities.

Input size: 133 characters.

Plain text or HTML input

Output

HTML Encoded. Output size: 213 characters.

How to use

  1. Paste your text or HTML, or open a file into the input box.

  2. Press Encode.

  3. Copy the result into your page, or download it as html-encoded.txt.

  4. Use the switch above the editor to open the HTML Entity Decoder and check it.

Why use this tool

  • Five characters

    & becomes &amp;, < becomes &lt;, > becomes &gt;, the double quote becomes &quot; and the single quote becomes &#39;.

  • 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.