URL Encoder Decoder: What is URL Encoding and Why It Matters
URL encoding — also called percent-encoding — is one of the quiet workhorses of the web. Every time you click a search result, submit a form, or share a link that contains a space, an emoji, or a Chinese character, that data has to be translated into a format that survives the trip through the network. URL encoding is the rulebook that makes this possible, and a URL encoder/decoder is the tool that applies and reverses it for you.
What Is URL Encoding?
A URL is not allowed to contain arbitrary bytes. The URI specification reserves a small set of "safe" characters — basic Latin letters, digits, and a few symbols such as - _ . ~ — and treats everything else as unsafe. Unsafe characters must be represented using a percent sign followed by two hexadecimal digits that describe the underlying byte.
For example, a single space becomes %20, an ampersand becomes %26, and a slash inside a path segment becomes %2F. The receiving server decodes these sequences back into the original characters before processing the request.
How Percent-Encoding Actually Works
The detail most people miss is that encoding operates on bytes, not on characters. Non-ASCII text such as "中文" or "café" is first converted to UTF-8, and then each resulting byte is percent-encoded. That is why the same word can produce a long, seemingly random string of %XX pairs — each pair is one UTF-8 byte. A correct URL encoder always uses UTF-8 as the source encoding; older systems that used a different charset are a common source of mojibake (garbled text).
Characters You Almost Always Need to Encode
- Spaces — sent as
%20(or sometimes+inside form data). - & = ? # % — reserved characters that would otherwise change how the URL is parsed.
- Non-ASCII text — accented letters, Chinese, Japanese, Arabic, and emoji all require encoding.
- Control characters — never legal in a URL and must always be encoded or removed.
When to Use URL Encoding
GET parameters: any query value that may contain spaces, &, or non-Latin text must be encoded so the parameter boundary is preserved.
URL paths: file or page names with spaces or Chinese characters should be encoded before being placed in a link.
Form submission: the application/x-www-form-urlencoded format encodes field names and values the same way before they are sent.
Common Mistakes to Avoid
The most frequent bug is double encoding: encoding a string that was already encoded turns %20 into %2520, which decodes to the literal text "%20" instead of a space. Only encode a value once, at the point where it enters the URL. The second trap is encoding the entire URL — including its ? & = / structure — which breaks the address; encode the values, never the syntax.
When you need to embed binary or large data inside a URL or a data attribute, Base64 is usually a better fit than percent-encoding. See our Base64 encode guide for that use case.