About URL Encode Decode
Spaces, ampersands and accented letters break URLs unless they are written as percent escapes. The confusing part is that there is no single right answer. How you encode depends on what the text is: one value going into a query string, a complete address you want to keep working, or the body of a submitted form. Encoding with the wrong rules is a common source of broken links.
So you choose which case you have, and the result follows those rules. In the other direction it decodes escapes and tells you what went wrong when it cannot: which % is broken, or whether the bytes come from an older encoding. If the output still holds escapes, a note says it was probably encoded twice.
How it works
URL component uses encodeURIComponent, which escapes everything with a special meaning in URLs, including /, ?, & and =. Whole URL uses encodeURI, which leaves those alone so the address keeps its structure, and only escapes things such as spaces and accented letters. Form data follows the application/x-www-form-urlencoded rules: spaces become +, and !'()* are escaped as well.
Non-ASCII characters are converted to UTF-8 first, and each byte becomes one escape, so é turns into %C3%A9. Decoding runs the same rules in reverse. The form option is what turns + back into a space, and the whole-URL option deliberately leaves reserved escapes such as %2F encoded, because decoding them would change the address's structure.
How to use URL Encode Decode
- Under Direction, choose Encode or Decode.
- Under Encode as, choose URL component, Whole URL or Form data.
- Type or paste into the box, or press Upload. Try an example fills in text that shows the differences.
- Press Copy or Download. Use as input runs the result back through in the other direction.
One string, three sets of rules
name=José & Sons/café?ref=50%URL component:
name%3DJos%C3%A9%20%26%20Sons%2Fcaf%C3%A9%3Fref%3D50%25
Whole URL:
name=Jos%C3%A9%20&%20Sons/caf%C3%A9?ref=50%25
Form data:
name%3DJos%C3%A9+%26+Sons%2Fcaf%C3%A9%3Fref%3D50%25The whole-URL version keeps =, &, / and ? as they were. That is right for a complete address and wrong for a single value, where the & would end the parameter early.
When it helps
- Putting a search term or a redirect address safely into a query parameter
- Fixing an address with spaces or accented letters so it works when shared
- Reading a percent-encoded value you found in a log or an analytics report
- Reproducing a form submission by hand when testing an endpoint
Tips for a better result
- When in doubt, use URL component on each value and join them yourself. Encoding a finished URL as a component turns its
https://intohttps%3A%2F%2F, which is only right when that URL is itself a parameter. - A
%25in your output means a literal percent sign. Seeing%2520usually means something was encoded twice, since%25plus20decodes to%20. - To break a complete address into its decoded parts, the URL Parser is quicker than decoding it here.
Good to know
- Decoding assumes UTF-8. Older links with escapes such as
%E9for é fail with a message saying so, instead of guessing at the encoding. - It works on text, not on a URL's structure, so Whole URL will not fix an address that has a stray
&inside a value. - A lone percent sign in text you are decoding is reported as an error. Write it as
%25. - Upload reads plain text files of 5 MB or less.
Questions people ask
What is the difference between %20 and + for a space?
%20 works anywhere in a URL. + means a space only in form-encoded data, mostly query strings. In a path, + is a literal plus sign.
Which characters never get encoded?
In component mode, letters, digits and - _ . ! ~ * ' ( ) stay as they are. Form mode escapes ! ' ( ) * too.
Why do I get an error saying the escape is not valid UTF-8?
The bytes do not form a UTF-8 character. Either they come from an older encoding such as Latin-1, or the string was cut in the middle of a multi-byte character.
Should I encode a whole URL before putting it in a link?
Only with Whole URL, and only if it has unsafe characters such as spaces. If the URL is going inside another URL as a parameter, use URL component instead.
What to use next
- URL Parser: to read every part of a complete address
- Base64 Encode Decode: for data that needs to be wrapped, not percent-escaped
- HTML Entity Encoder Decoder: when text is going into HTML and not a URL
Last reviewed . Read our editorial policy.