What is html entity encoder and decoder?
HTML uses some characters as code, so to show them as text you must write them as entities. A less than sign becomes the entity lt and an ampersand becomes amp.
This tool encodes and decodes entities. It can also convert accented and non Latin characters to numeric entities for systems that do not support them.
How to use the html entity encoder and decoder
- Paste your text.
- Choose encode or decode.
- Copy the result.
How the html entity encoder and decoder works
Encoding replaces ampersand, less than, greater than and both quote types with their entities. With the extra option on, every character above standard ASCII becomes a numeric entity. Decoding uses the browser parser to turn entities back into characters.
Worked example
Common uses of the html entity encoder and decoder
- Showing code samples in a web page.
- Fixing broken characters in a CMS.
- Preparing text for XML or email templates.
- Learning about web security.
- Decoding entities in scraped data.
Tips and common mistakes
Always encode user supplied text before you show it in a page.
Decode only text you trust.
Background: what to know before you rely on it
HTML entities exist because angle brackets and ampersands have special meaning in markup. If a page prints user input without encoding, a visitor could insert a script that runs in other visitors browsers. That attack is called cross site scripting, and output encoding is one of its main defenses. Modern frameworks encode by default, but copy and paste work in editors and templates still needs care. Named entities are readable, while numeric ones work for any character.
Private, free and fast
This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all converters, or browse the full list of tools.
Field by field guide
- Input: Type or paste your text here. Use a new line for each entry where the label says so.
- Action: Choose one of: Encode; Decode.
- Also encode non English characters: Tick to turn this option on.
Change one field at a time to see how the result responds, and use the worked example above to check that you get the same answer.
Why entities exist
HTML reserves some characters, such as less than, greater than and the ampersand, for markup. To show them as text you write them as entities, such as < for the less than sign.
Expert tips
- Encode user supplied text before you place it in a page. This is a key defence against cross site scripting.
- Use named entities for common symbols, such as © for the copyright sign, and numeric entities for anything else.
- With UTF8 pages you usually do not need entities for accented letters, only for the reserved characters.
- In attributes, also encode quotation marks.
- Decode with care. Decoded text should never be inserted into a page without being encoded again for its context.
Encoding is context specific. What is safe in HTML text may not be safe in a script or a URL.
Frequently asked questions
Why encode HTML?
So that browsers show the characters instead of running them as code, which also helps prevent cross site scripting.
What is a numeric entity?
A code such as é that stands for one character by its number.
Does decoding run scripts?
No. The tool only reads the text value.
Is it the same as URL encoding?
No. URL encoding uses percent signs.
Guides that go with this tool
Related tools
URL Encoder and Decoder
URL encoding replaces unsafe characters with a percent sign and two hex digits so a link works...
Developer ToolsBase64 Encoder and Decoder
Base64 turns text or bytes into a safe string of letters and numbers. Choose encode or decode, paste...
Developer ToolsHTML Minifier
Paste your HTML and the minifier removes comments and extra whitespace between tags to reduce file size...
ConvertersMarkdown to HTML Converter
Type or paste Markdown to get HTML code and a live preview. It supports headings, bold, italic, links,...
ConvertersUnit Converter
Pick a category, choose the unit you have and the unit you want, then enter a value. The converter also...
ConvertersTemperature Converter
To convert Celsius to Fahrenheit, multiply by 9/5 and add 32. To convert Fahrenheit to Celsius, subtract...
Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional. Check critical conversions with an official source.