Guide
How HTML Entities Work (and When to Encode or Decode)
Learn what HTML entities are, why encoding prevents bugs and XSS, and how to convert between text and entities.
An HTML entity encoder converts characters like <, >, &, and quotes into their entity form (<, >, &, ") so they display as text instead of being interpreted as markup. A decoder reverses the process.
What HTML entities are
HTML entities are escape sequences that represent characters that are either reserved in HTML (like < and >) or hard to type (like © or é). They take the form &name; or &#number;. Browsers render them as the character they name.
Why encoding matters
If you display user input that contains <script> tags without encoding, the browser runs the script — a classic cross-site scripting (XSS) vulnerability. Encoding < and > as < and > makes the tags display as harmless text. Encoding is the first line of defence when showing untrusted content.
How to use an encoder/decoder
- To encode: paste text containing special characters and copy the entity-encoded output.
- To decode: paste text with entities and copy the plain-text result.
- Use encoding before displaying user content; use decoding when importing legacy content.
Examples
The text "a < b && b > c" encodes to "a < b && b > c" so it renders correctly in HTML. The entity "© 2024" decodes to "© 2024".
When an entity encoder/decoder is useful
- Safely displaying user-submitted text on a web page.
- Showing code snippets that contain HTML tags.
- Converting legacy entity-laden text back to readable characters.
- Inserting special symbols like ©, ™, or em dashes.
Put it into practice
Use the HTML Entity Encoder / Decoder right now — free, in your browser, no sign-up required.
Try the HTML Entity Encoder / DecoderMore guides
- How to Unscramble Letters Into Words
- How to Find Anagrams of Any Word
- How to Count Words, Characters and Reading Time Accurately
- How to Find Words by Pattern, Length and Letters
- How to Use a Random Word Generator for Games, Writing and Brainstorming
- How to Count Characters (With and Without Spaces)
- How to Convert Text Between Cases (UPPER, lower, Title, camelCase and More)
- How to Clean Up Messy Text (Spaces, Line Breaks and Whitespace)
Related free tools
More free online utilities that pair well with this one — same-category tools for the same task, plus handy extras from other categories.
More developer & security tools
- Base64 Encoder / DecoderConvert plain text or images to Base64 strings
- JWT DecoderDecode JSON Web Token header & payload
- HTML / CSS MinifierStrip whitespace and line breaks to compress code
- Cron Expression GeneratorBuild cron expressions & see next runs
- Curl-to-Code ConverterConvert curl commands to fetch, Python & PHP