Home › Generators & Text Tools › HTML Encoder
HTML Encoder
Paste code into a web page without encoding it and the browser happily eats your tags — angle brackets vanish, ampersands break links, and a stray quote wrecks your attributes. This free HTML encoder converts text to safe HTML entities, and decodes entities back to readable text, entirely in your browser.
0 characters in
0 characters out
Nothing leaves your device. The conversion happens in your browser — your text is never uploaded to any server.
How it works
Five characters do all the damage in HTML, so essential encoding replaces exactly those five with entities:
The essential level is what you want for showing code in a page or placing text inside an attribute: it neutralizes the markup characters and leaves everything else — including accented letters and emoji — exactly as typed, which is correct for any page served as UTF-8. The full level goes further and converts every non-ASCII character to a decimal numeric entity, like é for é. That was essential in the ASCII-only era and still earns its keep in email templates, legacy systems, XML feeds and anywhere the character encoding of the final file cannot be trusted.
Decoding runs the process backwards: named entities from the standard HTML set (things like ©, — and ), decimal entities like © and hexadecimal ones like © all become their characters again. An entity the tool does not recognize is left untouched rather than deleted, so decoding never silently loses part of your text — and the character counts under each box let you sanity-check the result, since encoded text is always longer than the original.
Worked example
Press Load a sample and the input fills with a line of real markup: <p class="intro">Fish & Chips — café quality, "best in town" < 5 stars</p>. Run the encoder at the essential level and every special character becomes an entity — the opening bracket turns into <, the ampersand into &, each quote into " — producing text you could paste into a tutorial and have it display as code instead of rendering as a paragraph. Switch to the full level and the é and — also convert, to é and —. Switch the mode to Decode and run it again, and the entities turn back into the original line, character for character.
Common encoding mistakes
The classic error is double encoding: encoding text that was already encoded, so < becomes &lt; and your readers see "<" printed on the page. It happens when a CMS or framework encodes on save and a template encodes again on display — encode once, as late as possible, at the point of output. The second mistake is encoding the wrong context: entities protect HTML text and quoted attribute values, but a value going into a <script> block or an href needs JavaScript or URL encoding instead — HTML entities inside a script are not decoded and will not protect you. And the third is decoding user input and then trusting it: decode for display to humans, never decode something and then insert it into a page as markup.
FAQ
What is HTML encoding and why do I need it?
HTML encoding replaces characters that have a special meaning in HTML — & < > and quotes — with entity codes like < so a browser displays them as text instead of treating them as code. You need it whenever you show code samples on a web page, put user text into a page safely, or include special characters in an attribute value.
What is the difference between named and numeric entities?
A named entity uses a word, like © for ©. A numeric entity uses the character's Unicode number, like © in decimal or © in hexadecimal. Named entities are easier to read but only exist for a limited set of characters; numeric entities work for every character, which is why this tool's full mode encodes non-ASCII text numerically.
Which characters must always be encoded?
In HTML text, & and < must always be encoded (& and <) or the browser may misread your content as markup. Inside attribute values, the quote character that wraps the value must be encoded too — " for double-quoted attributes, ' for single-quoted ones. Encoding > as well is optional but harmless, and this tool does it for completeness.
Does encoding protect against XSS?
Encoding user text before placing it in HTML is one of the core defenses against cross-site scripting, because it stops the browser from treating the text as code. But it is context-sensitive: text going into a JavaScript string, a URL, or an unquoted attribute needs different handling. Treat this tool as a helper for content and attributes in ordinary HTML, not as a complete security solution.
Is my text uploaded anywhere?
No. The encoding and decoding run entirely in your browser with JavaScript on this page. Nothing you paste here is sent to a server, stored, or shared — close the tab and it is gone.