Percent-encode special characters in a URL or query string parameter, or decode an already-encoded URL back to readable text.
URL encoding (also called percent-encoding) converts characters that are not allowed or have special meaning in a URL into a % followed by their two-digit hexadecimal ASCII code. For example, a space becomes %20, & becomes %26, and = becomes %3D.
URLs can only contain a limited set of characters from the ASCII character set. Any other characters — including spaces, non-ASCII Unicode characters, and reserved characters used as URL delimiters — must be percent-encoded before they can be safely used in a URL.
| Function | What it encodes | Use for |
|---|---|---|
encodeURIComponent |
Everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ) |
Query string values, path segments |
encodeURI |
Preserves URL structure characters like / ? # & = |
Encoding a complete URL |
Use encodeURIComponent when encoding a single query parameter value. Use encodeURI when encoding a full URL that already has its structure intact.
| Original | Encoded |
|---|---|
hello world |
hello%20world |
user@example.com |
user%40example.com |
price=10&qty=2 |
price%3D10%26qty%3D2 |
https://example.com/path |
https%3A%2F%2Fexample.com%2Fpath |
What is the difference between %20 and + for spaces?
Both represent a space, but in different contexts. %20 is the standard percent-encoding and works everywhere. + is used specifically in application/x-www-form-urlencoded data (HTML form submissions). This tool uses %20 for encoding and handles + as a space when decoding.
Should I encode the entire URL or just the parameter values?
Encode only the values you are inserting into query parameters, not the whole URL. Encoding the full URL with encodeURIComponent will also encode the ://, /, and ? characters, making the URL unusable.
This website may contain affiliate links. If you click on an affiliate link and make a purchase, we may receive a small commission at no additional cost to you.