URL Encoding vs HTML Character References
Choose percent encoding for a URL component or form value and HTML character references for an HTML context without confusing representation with sanitization.
Need To Check A Conversion?
Use the URL Encode tool for the direct action. This guide stays focused on the explanation, tradeoffs, mistakes, and reference context behind that task.
Choose By Destination
| Destination | Representation | Important distinction |
|---|---|---|
| One URI component | UTF-8 percent encoding | A complete URL has separate components |
| Form value | application/x-www-form-urlencoded | Space becomes + |
| HTML text or quoted attribute | HTML character references as needed | Context and safe sink still matter |
| JavaScript or CSS | Language-specific escaping | Neither URL nor HTML encoding is a universal substitute |
Plus And Percent Are Not Universal Rules
A literal plus remains plus in URI-component decoding, while a form decoder maps it to a space. A literal plus in form data must be encoded as %2B.
Decode one layer by default. Recursive decoding can turn literal percent sequences into new syntax and hide double-encoding defects.
Encoding Is Not Sanitization
Percent encoding does not make a redirect destination trustworthy. HTML character references do not sanitize arbitrary markup or make every DOM sink safe.
Validate values and choose a safe output API after decoding. Keep the original representation when troubleshooting.
Related Tools
References
- WHATWG URL Standard - Primary URL parsing and application/x-www-form-urlencoded algorithms.
- WHATWG HTML Standard - Character References - Primary HTML named character-reference definitions.
- OWASP Cross Site Scripting Prevention Cheat Sheet - Context-sensitive output encoding and safe-sink guidance.
Related Guides In This Category
Browse More Encoding Guides
Need the broader support library for this topic? Visit Encoding Guides for related references, comparisons, and practical background before returning to the exact tool.
Explore The Full Category
Need another related task? Open Encoding Tools for the full tool set, quick-reference examples, and related category paths.