URL Encoding Explained: Percent-Encoding, UTF-8, and Special Characters

5 min read

URL encoding (percent-encoding) converts special characters into a format that can be transmitted over the internet. Spaces become %20, ampersands become %26, and non-ASCII characters are encoded as UTF-8 byte sequences.

Why URLs Need Encoding

URLs can only contain a limited set of characters (RFC 3986): letters, digits, and a few special characters (-._~). Everything else must be percent-encoded.

Common Encodings

CharacterEncoded
Space%20 (or + in query strings)
&%26
=%3D
?%3F
#%23
/%2F
@%40

Unicode in URLs

Non-ASCII characters (like café) are first encoded as UTF-8, then each byte is percent-encoded: caf%C3%A9.

In JavaScript

encodeURIComponent("hello world & café")
// "hello%20world%20%26%20caf%C3%A9"

decodeURIComponent("hello%20world")
// "hello world"

Generate Clean URLs

Avoid encoding issues by using clean slugs. Our URL slug generator creates encoding-safe slugs automatically.