How to URL encode and decode
- Choose Encode to make text safe for a web address, or Decode to turn % codes back into readable text.
- Type or paste into the left box. The result updates as you type. When encoding, pick the style that fits what you are building (see below).
- When the text is a full link that starts with https:// or http://, the page also lists its parts, such as the host, the path and the fragment, and every query parameter decoded, one per row.
- Press Copy result, or Use result as input to flip the direction and check that a round trip gives back what you started with.
What URL encoding is
A web address can only contain a small set of characters: letters, digits and a few symbols. Everything else, including spaces, accented letters, other alphabets, emoji, and the symbols that have a job inside an address, has to be written as a percent sign followed by two hexadecimal digits. That is why a space becomes %20 and why “café” becomes caf%C3%A9. The method is called percent-encoding, and it is defined in RFC 3986.
A letter outside plain English takes more than one code, because the text is first turned into UTF-8 bytes and each byte is written separately. The “é” is two bytes, C3 and A9, so it is %C3%A9. An emoji such as 👋 takes four bytes and four codes. Decoding reverses the steps, and it needs every code in such a group to be present, which is why a half-copied group is reported as an error.
The three encoding styles
- Part of an address encodes everything except letters, digits and the symbols
- _ . ! ~ * ' ( ). Use it for one value that will sit inside a link, such as a search term, a name, or a whole link passed as a redirect parameter. It encodes/ ? # & = :, so the value cannot be mistaken for the structure of the address. It is the same as the JavaScript functionencodeURIComponent. - Whole address keeps the characters that give an address its structure (
: / ? # & = + $ , ; @) and encodes only what could not be there at all, such as spaces and accented letters. Use it to tidy a complete link someone typed with spaces in it. It is the same asencodeURI. Do not use it for a single value that might contain an & or a #, because those pass through untouched. - Form data follows the rules an HTML form uses when it sends data (called application/x-www-form-urlencoded): a space becomes
+, letters, digits and* - . _stay, and everything else is encoded. It is what you get when a form or a search box is submitted.
The option Also encode ! ' ( ) * goes one step further for the first style. The built-in browser functions leave those five symbols alone, but RFC 3986 reserves them, and some strict systems, such as signature checks for web services, expect them encoded. With the option on, only letters, digits and - . _ ~ are left as they are.
Space: %20 or +?
This is the most common source of trouble. In a web address, %20 always means a space. A + means a space only in form data, the query part after the ?, when it was produced by a form or a search. Within a path, such as /my+file.pdf, a + is a plus sign. So when you decode a path, leave Treat + as a space off; when you decode a query string from a search address, tick it. When the text contains + signs and the option is off, the page tells you, so a plus sign is never changed silently.
When decoding fails
The decoder says where the problem is and what kind it is. There are two causes. The first is a % that is not followed by two hexadecimal digits (0 to 9 and A to F). That usually means a real percent sign was never encoded, as in “50% off”, which should be written 50%25 off. The second is a group of codes that does not form valid UTF-8 text, such as %C3 on its own, which is only the first half of “é”. Tick Keep bad % codes as they are to decode everything that can be decoded and leave the broken pieces in place.
Text that was encoded twice
If a decoded result still has codes like %20 in it, or if you start from %2520, the text was encoded twice: the % of the first round was itself turned into %25. This happens when a value is encoded by one piece of code and then again by the library that builds the link. Tick Decode again if still encoded to unwrap up to five rounds, and the status line tells you how many were needed. Decoding too many times can damage text that contains a real percent code on purpose, so use the option only when you expect double encoding.
Splitting a link into its parts
Paste a complete link and the page lists its scheme (https), host, port if one is given, path, query and fragment, and then each query parameter as a name and a decoded value, in order. It uses the browser’s own address reader, the same one that the browser applies when you click a link, so the result matches what a real page would see. A repeated name, such as two tag parameters, shows as two rows. The host name is shown in lower case, as the browser reads it. This is a quick way to check a tracking link, to find out where a long redirect leads, or to read a link that came out of an email program with its codes intact.
Where you will meet URL encoding
- Search and filter addresses carry your query as
?q=red+shoesor?q=red%20shoes. - Redirect and callback links contain a whole address as a parameter, which has to be encoded so its own ? and & do not break the outer link.
- File names in links with spaces or accents are written with % codes.
- API calls put values into the query or path of a request, where one unencoded & or # changes the meaning of the request.
- Email links such as
mailto:use % codes for the subject and the body. - Links in QR codes should be encoded properly first; the QR code generator makes a code from the finished link.
Tips
- Encode each value, not the whole link. Build a link from pieces by encoding every value on its own as a part of an address, then joining them with ? and &. Encoding a finished link in that style also encodes the separators and breaks it.
- Do not encode twice. If the text already has % codes, decode it first, or you get %25 everywhere.
- Base64 is a different thing. A long mix of letters and digits, perhaps ending in =, is probably Base64; use the Base64 encoder and decoder. If a JSON value was pasted into a link, tidy it with the JSON formatter.
- Compare before and after. The text compare tool shows exactly which characters changed.
Your text stays on your device
Encoding, decoding and splitting a link all run in your browser, so nothing you type or paste is sent anywhere. Because addresses often hold tokens, session identifiers or passwords, the page does not keep your text at all: only your settings, such as the style and the checkboxes, are remembered on this device, and a reload starts with empty boxes.
Frequently asked questions
What is the difference between the three encoding styles?
Part of an address (the same as JavaScript’s encodeURIComponent) encodes every character that could mean something inside a web address, including / ? & = # and :, so it is right for a single value such as a search term or a redirect link placed in a query. Whole address (encodeURI) keeps those characters so a complete link still works, and only encodes spaces, accented letters and the like. Form data is the style an HTML form uses: spaces become + and the rest is encoded as for a part of an address.
Should a space be %20 or +?
%20 is correct everywhere in a web address. A + means a space only in form data, which is the part of an address after the ? when it came from a form or a search box. In a path such as /my+file the + is a real plus sign. When you decode text from a query string, tick “Treat + as a space”; when you decode a path, leave it off.
Why does my text show %2520 or %252F?
Text that has been encoded twice. The first round turned a space into %20, and the second round turned the % itself into %25, giving %2520. Tick “Decode again” in the decoder and it is unwrapped until no codes are left. If you control the code that builds the link, find the place where the value is encoded a second time and remove it.
Why does decoding say my text is not valid?
The message gives the position of the first problem. Either a % is not followed by two hexadecimal digits (for example a real percent sign in “50% off”, which should have been written %25), or a group of % codes does not make valid UTF-8 text, usually because part of an accented letter or emoji is missing. Fix the position it names, or tick “Keep bad % codes as they are” to decode everything else.
Is my text uploaded?
No. Encoding, decoding and splitting an address all run in your browser, so nothing you type or paste is sent to this website or anywhere else. The page remembers only your settings on this device, not your text, because a web address can contain a token or a password.
Is URL encoding a way to hide or protect data?
No. Percent-encoding only makes characters safe to place in a web address. Anyone can decode it in a second, with this page or with built-in tools, so never rely on it to hide a password, a key or any private value.