HTML Encoder & Decoder
Convert HTML special characters to safe entities — and back again — so code displays as text on a web page instead of being read as markup.
Result
How It Works
Web browsers read certain characters as instructions: < starts a tag, & starts an entity, and quotes delimit attributes. So to display the text <p>Hello</p> instead of rendering a paragraph, each special character must become an entity — < for <, > for >, & for &, " for quotes and ' for apostrophes. This tool converts in both directions.
Encoding also handles common named entities beyond the big five: the copyright sign becomes ©, the euro sign €, the em dash —, and curly quotes become “, ”, ‘ and ’. Decoding reverses all of them, including numeric entities such as ' and hexadecimal ones such as '. It is careful about order: &lt; decodes to the literal text <, not to <, because the ampersand is decoded last.
Worked Example
Encode <p class="hi">Tom & Jerry</p> and you get <p class="hi">Tom & Jerry</p> — every angle bracket, quote and ampersand replaced, so the whole string can be pasted into a web page and shown as code. Encode café — 50€ and you get café — 50€ — the dash and euro sign become named entities while the é stays as it is. Decode <b>Hi</b> and you get <b>Hi</b> back.
How to Use This Tool
Paste your code or text into the box and press Encode Entities to convert it, or paste entity-filled text and press Decode Entities to reverse it. The result appears below with the character counts for the input and the output, and Copy Output copies the result to your clipboard.
Tips and Practical Advice
- Always encode user content before showing it as HTML. Unencoded input is how cross-site scripting attacks happen — encoding turns dangerous tags into harmless visible text.
- Encode the ampersand first. If you replace
<before&, the&in<gets encoded again and you end up with&lt;. This tool handles the order for you. - Check for double-encoding. If a page shows the literal text
<instead of<, the content was encoded twice — decode once to fix it.
Last updated: