HTML Entity Encoder Online
Runs in your browserEncode HTML special characters into entities online for free, so markup can be shown as text. Encode again for nested cases. Runs in your browser.
HTML Escaping at a Glance
These are the characters the encoder replaces, and why each one matters inside HTML.
| Character | Entity and reason |
|---|---|
| & | Written as &, so an ampersand is not read as the start of an entity. |
| < and > | Written as < and >, so text cannot open or close a tag. |
| " | Written as ", so a value inside a quoted attribute cannot end early. |
| ' | The apostrophe is written as ', which is safe in single-quoted attributes too. |
| Example | <b>Tom & Jerry</b> is written as <b>Tom & Jerry</b>. |
How to Use the HTML Entity Encoder Online
- Paste your text or markup
Type or paste the text or HTML snippet into the box, for example a code sample you want to show on a web page.
- Press Encode HTML
The characters & < > quotes and apostrophes are replaced by entities such as & < and >. Press again to encode the result a second time if a template requires it.
- Copy or download
Copy the escaped output into your page or template, or download it as a text file.
When to Escape HTML
Escape text whenever it must appear on a web page as written, not as markup. Typical cases are showing code samples in a tutorial, displaying user comments, and writing examples of HTML in documentation. Without escaping, a snippet such as a script tag would be executed by the browser instead of shown.
Escape only once for values that go into HTML. Encoding an already escaped string turns the existing & into &, so the reader would see the entity code itself. Use the HTML entity decoder if you need to check what a value says.
Escaping is a display safety measure, not a complete defence. Templates, frameworks and databases each have their own escaping rules. Use the escaping your framework provides for production data, and treat this tool as a way to prepare samples and check output.
Things to Know
Privacy
Encoding runs in your browser. The text you paste is never uploaded, logged or stored.
Frequently Asked Questions
How do I HTML encode text online?
Paste the text into the box and press Encode HTML. The characters & < > quotes and apostrophes become entities.
Which characters are encoded?
Ampersand, less-than, greater-than, double quote and single quote. Everything else, including accents and emoji, is left as it is.
Why should I escape HTML?
So text shows on a page exactly as written instead of being read as markup. It is the main protection against accidentally running a snippet of code.
Can I encode a whole web page?
You can, but you usually do not want to. Escaping a page turns its tags into visible text. Encode only the text or sample you want to display.
Does this change how my text looks in a browser?
Not once it is displayed. The entities render as the original characters, so readers see the same text.
Is my text sent to a server?
No. Encoding runs in your browser, and nothing you paste is uploaded or stored.