6 min read
How URL Encoding Works
Understand percent encoding, reserved characters, and the difference between a URL and one URL component.
Reserved characters
URLs use characters such as ?, &, =, /, and # as structure. When one of those characters belongs inside a value, percent encoding represents its UTF-8 bytes safely.
Encode the right scope
encodeURIComponent is appropriate for a query value or path segment. Encoding a complete URL with it also hides structural separators and usually produces the wrong result.
