My Tool Studio
Developer

HTML Entity Encoder

Display a code snippet on a web page without escaping it first and the browser will try to render it. That's the problem html entities solve, and this tool converts in both directions. Encode replaces the five risky html characters, meaning the ampersand, both angle brackets, and both quote styles, with their entity forms so they display as text instead of acting as markup. Decode reverses the trip, turning & or a numeric code back into the real character. It's a small html escape step that closes off the most common XSS vector: user input echoed straight into a page.

Always freeNo sign upRuns in your browser
Output appears here...

How to use

01

Paste text or markup

Add the string you need to escape, or the entity-filled HTML you want to read. The Try sample button loads a link tag with an ampersand and quotes.

02

Click Encode or Decode

Encode swaps the special characters for entities. Decode expands named entities plus decimal and hex codes, so © and © both come back as the copyright sign.

03

Copy the safe output

Use the Copy button to move the escaped string into your template or attribute, or the decoded text back into your editor.

Why HTML Entity Encoder

Common questions

What do HTML entities actually protect against?
They stop the browser from mistaking data for markup. If a commenter writes a script tag and you print it raw, the browser runs it; print <script> instead and it displays harmlessly. Encoding user input this way is the classic defense against stored XSS.
Which characters does the encoder replace?
Five of them: & becomes &amp;, < becomes &lt;, > becomes &gt;, the double quote becomes &quot;, and the apostrophe becomes &#39;. These are the html character codes that matter for safety; accented letters are left alone because modern UTF-8 pages don't need them escaped.
Does html decode handle numeric character references?
Yes, both flavors. Decimal references like &#169; and hex ones like &#xA9; are converted, along with the common named set including &amp;, &lt;, &gt;, &quot;, and &nbsp;. That makes html decode online useful for reading text copied out of feeds or scraped pages that arrive full of entity soup.
Is there a difference between html character entities and character codes?
Only naming. The phrase html character entities usually means the named forms like &amp;, while a numeric reference points at the character's code position instead. Both spell out the same characters, and the Decode button handles either style.
When should I html encode attribute values?
Any time a value contains quotes or ampersands and comes from data you don't control. An unescaped double quote inside href or title ends the attribute early and lets the rest of the string inject markup. Running the value through html encode online first keeps the attribute sealed.
Can this tool parse or restructure a whole document?
No. It's an entity tool, not an html parser online, and it won't reorganize markup the way a general html converter would. For indentation and structure, the HTML Beautifier is the right page; come back here when individual characters need escaping.
Do I need separate tools for each direction of html encode decode?
No, the pair lives on one page. Encode before you publish untrusted text, then paste anything suspicious back later and decode it to audit what was stored. Round-tripping a string is also a quick html entity decode test when output looks doubled, like seeing &amp;amp; on a live page.

More Developer tools

View all