URL encoding (also known as percent-encoding) is a mechanism that converts special characters in a URL into the %XX format, where XX is the hexadecimal representation of the character's ASCII/UTF-8 byte. The URL standard is defined in RFC 3986, which specifies that URLs may only contain ASCII letters, digits, and a few reserved characters. All other characters must be encoded.
& = ? in values break the URL structureLocation headers or redirect parametersJavaScript provides two URL encoding functions. The core difference is how they handle reserved characters:
β’ encodeURI: Encodes a complete URL, preserving structural characters ; , / ? : @ & = + $ #. Use this when encoding a full URL address.
β’ encodeURIComponent: Encodes a URL component (such as a parameter value), encoding all reserved characters, ensuring that special characters in the value do not break the URL structure.
Simple rule: Use encodeURI for entire URLs, use encodeURIComponent for parameter values.
| Character Type | Characters | encodeURI | encodeURIComponent |
|---|---|---|---|
| Alphanumeric | A-Z a-z 0-9 | Preserved | Preserved |
| Unreserved symbols | - _ . ! ~ * ' ( ) | Preserved | Preserved |
| URL structure chars | ; , / ? : @ & = + $ # | Preserved | Encoded as %XX |
| Space | (space) | Encoded as %20 | Encoded as %20 |
| Unicode chars | e.g. CJK | Encoded as %XX | Encoded as %XX |
| Other special chars | < > " { } | \ ^ ` | Encoded as %XX | Encoded as %XX |
?q= (search keyword encoded as a parameter value)?redirect= (target URL encoded as a parameter value, use encodeURIComponent)# (encode special characters in the fragment)mailto:?subject= (encode email subject)/path/ (encode path segment with special characters)Each encoded character becomes 3 characters (e.g. a space becomes %20). Characters that occupy multiple bytes in UTF-8 will expand further β for example, a 3-byte CJK character becomes 9 characters after encoding. URLs containing many non-ASCII or special characters will increase significantly in length after encoding.
If you are encoding an entire URL (with protocol, domain, path), use encodeURI, which preserves :/?#&= and other structural characters. If you are encoding a specific parameter value or fragment within a URL, use encodeURIComponent, which encodes all special characters to prevent them from breaking the URL structure.
Yes. JavaScript's encodeURI and encodeURIComponent automatically convert Unicode characters to percent-encoding using UTF-8. This tool fully supports Chinese, Emoji, and all Unicode characters.
encodeURI and encodeURIComponent encode a space as %20. In the application/x-www-form-urlencoded format (such as form submissions), a space is encoded as +. This tool uses the standard %20 encoding. If you need + encoding, you can replace it manually.
After checking "Batch mode", the tool processes each line in the input box separately, one URL per line. Empty lines are preserved. If a line fails to decode, an error message is shown for that line without affecting other lines.
No. URL encoding is an encoding scheme, not encryption. Anyone can decode it and it provides no security. Its purpose is to ensure that special characters in URLs are correctly transmitted and parsed, not to protect data. For secure transmission, use HTTPS or a real encryption algorithm.