URL encoding (also called percent-encoding) replaces characters that aren't allowed or don't have a defined meaning in a URL — spaces, `&`, `?`, `#`, accented letters, and more — with a `%` followed by their hexadecimal byte value. This lets arbitrary text be safely embedded as part of a URL, such as in a query string parameter.
This is essential whenever user-provided text ends up in a link — a search query, an email address passed as a parameter, or a redirect target — since unencoded special characters can break the URL's structure or be interpreted as a separate parameter.
This tool encodes using encodeURIComponent, the same function browsers and JavaScript use to encode a single query string value (as opposed to encodeURI, which is meant for encoding a whole URL and leaves characters like / and & untouched).
What's the difference between encodeURIComponent and encodeURI?
encodeURIComponent (used here) escapes nearly every reserved character and is meant for a single query parameter value; encodeURI leaves characters like / and & untouched since it's meant for encoding a whole URL.
Why do spaces become %20 and not +?
%20 is the correct percent-encoding for a space in a URL path or component; + for spaces is a form-encoding (application/x-www-form-urlencoded) convention, only valid in query strings built that way.
Does this handle Unicode characters?
Yes — non-ASCII characters are first UTF-8 encoded, then each byte is percent-encoded.