Last updated 23 August 2026
Two different jobs
URL encoding escapes characters that would otherwise break a URL's structure — spaces become %20, & becomes %26, and so on — so a value can safely sit inside a query string or path segment.
HTML entity encoding escapes characters that have a special meaning in HTML markup — <, > and & — so text displays literally instead of being mistaken for a tag or entity reference. A price like "<$50" needs entity-encoding before it can safely appear in a web page.
Common questions
When do I need URL encoding?
Whenever a value goes inside a URL and might contain characters that have a special meaning there — spaces, &, ?, # and others. Encoding replaces them with a %-escaped form so the URL still parses correctly.
Why do I see & instead of & on a web page?
In HTML, & starts an entity reference, so a literal ampersand has to be written as & to display correctly. The same applies to < and >, which would otherwise look like the start of a tag.
Is URL encoding the same as HTML entity encoding?
No — they solve different problems. URL encoding protects characters that are special inside a URL. HTML entity encoding protects characters that are special inside HTML markup. A value might need one, the other, or occasionally both, depending on where it ends up.