What Is URL Encoding?
URL encoding (also called percent-encoding) converts characters that aren't allowed directly in URLs into a %XX format, where XX is the hexadecimal value of the character's UTF-8 byte(s). Examples:
- Space →
%20(or+in form data) &→%26=→%3D- Chinese "你好" →
%E4%BD%A0%E5%A5%BD
Why Is URL Encoding Necessary?
The URL standard (RFC 3986) only permits specific ASCII characters. When a URL needs to include special characters, they must be encoded first:
- Reserved characters (
: / ? # [ ] @ ! $ & ' ( ) * + , ; =) have special meaning in URLs — encode them when using them as data - Non-ASCII characters (Chinese, Japanese, symbols) are outside the allowed URL character set
- Spaces cannot appear directly in URLs — must be
%20or+
encodeURI vs. encodeURIComponent (JavaScript)
| Function | Does NOT encode | Use when |
|---|---|---|
encodeURI() | Letters, digits, - _ . ! ~ * ' ( ), URL structure chars (: / ? # @ & = + $ ,) | Encoding a complete URL — preserves URL structure |
encodeURIComponent() | Letters, digits, - _ . ! ~ * ' ( ) only | Encoding a single query parameter value |
// Encode a full URL (preserves / ? = & structure)
encodeURI('https://example.com/search?q=hello world')
// → 'https://example.com/search?q=hello%20world'
// Encode a parameter value (& and = also get encoded)
encodeURIComponent('hello & world=1')
// → 'hello%20%26%20world%3D1'
How to Encode or Decode URLs Online
Use tool.tl's URL encoder or URL decoder: