HTML entities explained: when & and < actually matter
An HTML entity is a way to write a character that would otherwise be read as markup or that is hard to type. The ampersand, the less-than sign and the quotation mark all have special meanings in HTML, so a page that shows them as plain text has to write them as entities. Most of the time a template or a framework does this for you. The cases where it does not are where bugs and security holes appear.
The entities you meet every day
Five named entities cover most of the cases:
&stands for&(the ampersand itself)<and>stand for<and>, so text like<script>is shown and not run"and'stand for quotation marks inside attribute values
is a non-breaking space. It looks like a space but it does not allow a line break, which is why it appears in prices and addresses.
Numeric references
Any character can be written by its code point. © is the decimal reference for the copyright sign and © is the same character in hexadecimal. Numeric references are useful when a named entity does not exist or when you need one character from a large set.
Why escaping is a security matter
If user input is inserted into a page without escaping, a visitor can type markup and have it run in other people's browsers. Escaping < and > turns that markup into harmless text. Escape at the point of insertion, for the context you insert into. Text in an HTML body, an attribute value and a URL each need different treatment.
Encoding and decoding
The HTML entities tool converts text to entities and back in your browser. Use it to check what a string looks like once it is escaped, or to read an entity-heavy export. Nothing you paste is uploaded.
A quick checklist
- Escape user input when you put it into HTML, not when you store it.
- Remember that a value inside an attribute needs quotes escaped too.
- Do not rely on entities to hide data. They are a presentation format, not encryption.
Creator of TextArray — building free, privacy-first tools that run entirely in your browser.