URL Decode and Encode
Percent-encode or decode text, choose between encodeURIComponent and encodeURI, and parse any URL into its parts and decoded query parameters.
Open source on GitHubText to encode
Component (encodeURIComponent) escapes everything except A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use it for a single query value or path segment.
Encoded
Runs entirely in your browser. Nothing you paste here is uploaded or stored.
Which encoding function to use. What each JavaScript function escapes.
| Function | Escapes | Use for |
|---|---|---|
| encodeURIComponent | Everything except A–Z a–z 0–9 - _ . ! ~ * ' ( ) | A single query value, path segment, or redirect URL passed as a parameter |
| encodeURI | Same, but keeps ; , / ? : @ & = + $ # | A complete URL that only needs spaces and non-ASCII characters escaped |
| URLSearchParams | Like encodeURIComponent, but spaces become + and ! ' ( ) ~ are also escaped | Building form-encoded query strings and POST bodies |
Common percent-encoded characters. Reserved characters and how they are encoded.
| Character | Encoded | Notes |
|---|---|---|
| Space | %20 | + in form data (application/x-www-form-urlencoded) |
| ! | %21 | Not escaped by encodeURIComponent |
| # | %23 | Starts the fragment |
| $ | %24 | Reserved sub-delimiter |
| % | %25 | Escape character itself |
| & | %26 | Separates query parameters |
| + | %2B | Means space in form data, so encode it in values |
| , | %2C | Reserved sub-delimiter |
| / | %2F | Separates path segments |
| : | %3A | Separates scheme, port, and credentials |
| = | %3D | Separates a query key from its value |
| ? | %3F | Starts the query string |
| @ | %40 | Separates credentials from host |
| é | %C3%A9 | Non-ASCII characters are encoded as UTF-8 bytes |
More free tools. Free, open source, no sign-up. See all tools · Source on GitHub
Frequently asked questions
What is URL encoding?
URL encoding, or percent-encoding, replaces characters that are not allowed or have special meaning in a URL with a % followed by two hex digits. A space becomes %20, & becomes %26, and non-ASCII characters are encoded as their UTF-8 bytes, so “é” becomes %C3%A9.
Should I use encodeURIComponent or encodeURI?
Use encodeURIComponent for pieces of a URL: a query value, a path segment, or a whole URL you pass as a parameter (like redirect_uri). Use encodeURI only on a complete URL, because it leaves delimiters such as / ? & = # intact. Using encodeURI on a query value is a common bug: an & inside the value will split it into two parameters.
Why is a space sometimes + and sometimes %20?
In the query string of HTML form submissions (application/x-www-form-urlencoded), a space is written as +. Everywhere else in a URL, a space is %20. When decoding form data, turn on “Treat + as space”; otherwise a literal + is kept.
Why does my decoded URL still contain %20 or %2F?
The value was probably encoded twice, for example %2520 instead of %20 (%25 is the encoded % sign). This happens when a framework encodes a value that was already encoded. The tool flags still-encoded output and lets you decode again, but the real fix is to encode exactly once.
What causes “URI malformed” errors?
decodeURIComponent throws when a % is not followed by two hex digits, or when the bytes do not form valid UTF-8, for example a literal “100%” or text encoded as Latin-1 (%E9 for é). This tool shows the position of the first bad sequence.