How to encode or decode a URL
- Choose Encode or Decode at the top of the tool.
- Type or paste into Text to encode (or Encoded string to decode). The page opens with an example already filled in.
- When encoding, pick a method: encodeURIComponent, encodeURI (whole URL), RFC 3986 strict or Form (+ for spaces). When decoding, tick or clear Treat + as a space (form data).
- Click Copy, or Swap to move the result back into the input and flip the mode, which shows whether your text survives the round trip.
- Use Break a URL into parts to inspect a link and Build a query string to assemble parameters.
How percent-encoding works
Percent-encoding, defined in RFC 3986 section 2.1, writes each byte of a character's UTF-8 form as a percent sign and two hex digits, so the Japanese character 日 becomes %E6%97%A5. The four methods differ only in which characters they leave alone. The JavaScript behavior follows MDN, and the form rules follow the WHATWG URL Standard.
| Method | Characters left as they are |
|---|---|
| encodeURIComponent | A-Z a-z 0-9 - _ . ! ~ * ' ( ) |
| encodeURI | The same, plus ; , / ? : @ & = + $ # |
| RFC 3986 strict | A-Z a-z 0-9 - _ . ~ |
| Form (+ for spaces) | A-Z a-z 0-9 - _ . *, and a space becomes + |
Worked example
The default input is Crème brûlée & coffee: 5% off (today)!. With encodeURIComponent the tool shows:
Cr%C3%A8me%20br%C3%BBl%C3%A9e%20%26%20coffee%3A%205%25%20off%20(today)!
With RFC 3986 strict the parentheses and the exclamation mark are encoded too:
Cr%C3%A8me%20br%C3%BBl%C3%A9e%20%26%20coffee%3A%205%25%20off%20%28today%29%21
Limits and edge cases
- Decoding never fails outright. A stray percent sign or a broken UTF-8 sequence is left as typed and flagged, and the rest is decoded.
- encodeURI also escapes
[and], so do not use it on a URL with an IPv6 address. - A redirect URL placed inside another URL is encoded once with encodeURIComponent, not twice.
- The parser needs a scheme such as
https://or a host name with a dot. It hides any password and lists repeated parameters separately. - The query string builder skips rows with an empty name. Text containing half of a character pair, such as a cut-off emoji, cannot be encoded.
Frequently asked questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI is for a whole URL. It leaves characters that have a job in a URL, such as : / ? # & = and +, alone. encodeURIComponent encodes those too, so it is the right choice for one query value or path segment. Running encodeURI on a value that contains an ampersand leaves the ampersand in place and breaks the query string.
Should I use + or %20 for a space?
A plus sign means a space only in form data and query strings (application/x-www-form-urlencoded). In a path or fragment a space must be %20. Because %20 is also accepted in query strings, it is the safer default.
Why does my decoded text still contain plus signs?
A plus sign is only turned into a space for form data. Tick Treat + as a space (form data) when you decode a query string or form body. Leave it off for paths and for text that really contains plus signs, such as phone numbers or Base64.
Why does my URL show %2520 instead of %20?
The text was encoded twice. The first pass turned a space into %20, and the second pass turned the percent sign into %25. Decode it once more, or encode the original text only one time.
Related tools: Base64 encoder and decoder for binary data, the HTML entity encoder for text inside web pages, and the JSON formatter for API payloads.