Encode or decode URL components. Convert special characters, spaces, and Unicode into percent-encoded format (and back).
URL encoding (also called percent-encoding) converts characters that are not allowed in URLs into a format that can be transmitted over the Internet. For example, spaces become %20and Chinese characters like “你好” become %E4%BD%A0%E5%A5%BD.
This is essential when you need to include special characters, non-ASCII text, or reserved characters (like &, ?, =) in a URL query string.
Common characters and their percent-encoded forms:
Space -> %20 & -> %26 ? -> %3F = -> %3D / -> %2F # -> %23 % -> %25 你好 -> %E4%BD%A0%E5%A5%BD
Example. The search query Hello world & friends encoded becomes Hello%20world%20%26%20friends.
What is the difference between encodeURIComponent and encodeURI?
encodeURIComponent escapes almost everything, including /, ?, and &, making it the right choice for query parameter values. encodeURI leaves structural characters intact and is meant for full URLs.
Why does a space encode to %20 instead of +?
In query strings, + is a legacy way to represent a space (used by form submissions). Standard URL encoding uses %20 for a space everywhere.
Do I need to encode non-ASCII characters?
Modern browsers often handle Unicode directly, but many APIs and legacy systems expect percent-encoded UTF-8. Encoding is always the safe choice for maximum compatibility.
Can URL encoding be reversed automatically?
Yes. Decoding turns %XX sequences back into their original characters, so you can round-trip encoded URLs back to plain text for debugging.
Is my URL sent to a server?
No. Both encoding and decoding happen entirely in your browser, so you can safely process sensitive URLs and tokens without them leaving your device.
:// and / structure.+ for spaces in non-form contexts.% into %25.