HTML entities write special characters as safe text, such as < for < and & for &. Encoding is how you show markup as text on a page and avoid breaking HTML, while decoding turns entities back into the characters they represent.
Common uses
- Decoding a Base64 value found in a header or config file
- Percent-encoding a query parameter that contains spaces or symbols
- Embedding a small image in CSS or HTML as a data URI
Frequently asked questions
- Does encoding prevent XSS?
- Encoding output for the right context is a core defense, but it must be applied where the data is inserted. Use your framework escaping rather than manual steps in production.
- Are named and numeric entities both supported?
- Yes. Both © and © decode to the same character.