Developer
URL encoder / decoder
Percent-encodes a text for use in a URL parameter, and decodes an encoded string back to readable text. Type in either box.
Uses encodeURIComponent: unaccented letters, digits and the characters - _ . ! ~ * ' ( ) are left as they are, everything else is encoded.
How to use this tool
There are two boxes. Type or paste plain text on the left and its encoded form appears on the right; paste an encoded string on the right and the readable text appears on the left. Encoding uses the JavaScript function encodeURIComponent: each character outside the safe set is turned into its UTF-8 bytes, each written as a percent sign and two hexadecimal digits. A space becomes %20, an ampersand %26, and é becomes %C3%A9 because it takes two bytes. Letters, digits and the characters - _ . ~ ! * ' ( ) are left alone. Because / ? & = and : are encoded too, the tool is meant for one value at a time, such as a search term or a parameter: run a whole address through it and the address stops working as a link. Decoding shows an error if a percent sign is not followed by two valid hexadecimal digits.
Concrete examples
- hello world → hello%20world
- café & tea → caf%C3%A9%20%26%20tea
- ?q=search → %3Fq%3Dsearch
- tom@example.com → tom%40example.com
- 100%25%20sure → 100% sure (decoding)
Frequently asked questions
- What is the difference between encodeURI and encodeURIComponent?
- encodeURI is for a complete address: it leaves : / ? # & = untouched so the URL keeps its structure. encodeURIComponent, used here, encodes those too, which is what a single value placed inside a URL needs. "rock/pop" becomes rock%2Fpop, so the slash is not mistaken for a path separator.
- Why is a space encoded as %20 instead of a plus sign?
- %20 is the percent-encoding of the space character and is valid in every part of a URL. The plus sign is a convention of HTML form submissions and only applies to the query string. This tool writes %20 when encoding and does not turn + back into a space when decoding: a+b stays a+b.
- Why do accented letters take several codes?
- Each character is first converted to UTF-8, then every byte gets its own %XX code. An unaccented letter needs no encoding, é takes two bytes (%C3%A9), the euro sign three (%E2%82%AC) and most emoji four. This is why an encoded address in another alphabet looks so long.
- Why do I get an invalid encoding error?
- The decoder expects every percent sign to be followed by two hexadecimal digits that form valid UTF-8. A lone % as in "100% sure", a cut-off sequence such as %C3 on its own, or text that was encoded in Latin-1 all trigger the error. A literal percent sign must be written %25.