Encode special characters for safe use in URLs or decode percent-encoded strings back to readable text. Uses standard percent-encoding (RFC 3986).
Common Encodings
| Character | Encoded | Character | Encoded |
|---|---|---|---|
| Space | %20 | & | %26 |
| = | %3D | ? | %3F |
| / | %2F | # | %23 |
| @ | %40 | + | %2B |
URL encoding (also called percent-encoding) replaces unsafe or special characters in a URL with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII value. For example, a space becomes %20, and an ampersand (&) becomes %26. This ensures that special characters do not break the URL structure.
URLs can only contain a limited set of ASCII characters. Characters like spaces, &, =, ?, /, #, and non-ASCII characters (accented letters, Chinese characters, emojis) must be encoded to be safely included in a URL. Without encoding, these characters could be misinterpreted as URL delimiters or cause parsing errors.
JavaScript provides two encoding functions. encodeURIComponent() encodes everything except letters, digits, and a few special characters (- _ . ! ~ * ' ( )). It is used for encoding URL parameter values. encodeURI() preserves the URL structure characters (:, /, ?, #, &, =) and only encodes characters that are not valid anywhere in a URL. This tool uses encodeURIComponent for the most thorough encoding.
Proper URL encoding is essential for building API requests, constructing query strings, embedding user input in URLs, and ensuring web applications handle special characters correctly across all browsers and servers.