Skip to content
tools.best

Browse all tools

URL Decoder and Encoder

This URL decoder and encoder turns a percent-encoded URL back into readable text, or makes text safe for a URL: %20 becomes a space, %26 becomes &.

Runs in your browser. Your text is not sent to a server. Sources: RFC 3986 Updated

Direction
62 characters
56 characters

How URL percent-encoding works

A URL may only contain a limited set of characters. Anything else, and any reserved character that should be read as plain text, is written as a percent sign followed by the two hexadecimal digits of each of its UTF-8 bytes.

character → UTF-8 bytes → %XX for each byte    (space → byte 20 → %20)

Letters, digits and - . _ ~ are never encoded. Decoding is the reverse: every %XX becomes a byte and the bytes are read as UTF-8.

The two digits after each % are the byte in hexadecimal, the same notation the text to hex converter uses, and the byte values of the basic Latin characters are listed on the ASCII to text page. A string of letters, digits and + / = without percent signs is more likely Base64; the Base64 decoder reads it.

How to decode a URL: a worked example

Decoding https://example.com/search?q=hello%20world%26more&lang=de%2DCH:

  1. %20 is byte 20, a space: hello world
  2. %26 is byte 26, an ampersand that belongs to the search term: hello world&more
  3. %2D is byte 2D, a hyphen. It did not need encoding, but decoding it is harmless: de-CH
  4. Result: https://example.com/search?q=hello world&more&lang=de-CH

In the other direction, the value hello world&more=é encodes to hello%20world%26more%3D%C3%A9. The é takes two escapes because it is two bytes in UTF-8. Encode a link this way before you put it into a QR code, and count the escapes: each one is three bytes the code has to hold.

URL encoding of six characters: the space is byte 20 and becomes %20, & becomes %26, = becomes %3D, / becomes %2F, é is the two bytes c3 a9 and becomes %C3%A9, and ~ is not encoded.
Encoded as a value, every reserved character is escaped, including the / and = that structure a URL.

URL encoding table: reserved characters and codes

CharacterCodeEscaped as a valueEscaped in a whole URL
space%20yesyes
!%21nono
"%22yesyes
#%23yesno
$%24yesno
%%25yesyes
&%26yesno
'%27nono
(%28nono
)%29nono
*%2Anono
+%2Byesno
,%2Cyesno
/%2Fyesno
:%3Ayesno
;%3Byesno
<%3Cyesyes
=%3Dyesno
>%3Eyesyes
?%3Fyesno
@%40yesno
[%5Byesyes
]%5Dyesyes

The two right-hand columns show what the Encode button does, which is what JavaScript's encodeURIComponent and encodeURI do. Both leave ! ' ( ) * alone; these are valid in a URL and rarely cause trouble, but some APIs want them escaped as well.

URL Decoder and Encoder: FAQ

What does %20 mean in a URL?
It is an encoded space. A percent sign followed by two hexadecimal digits stands for one byte, and 20 is the byte value of the space character. hello%20world decodes to hello world.
What is %3D in a URL?
An encoded equals sign: 3D is the byte value of =, so a%3Db decodes to a=b. In a query string a plain = separates a name from its value, so an = that belongs inside a value, such as the padding at the end of a Base64 string, is written as %3D. The URL encoding table on this page lists the code of every reserved character.
Why does a + sometimes mean a space?
HTML forms encode a space as + in the query string, a convention older than the URL standard. In the rest of a URL a plus is just a plus. Tick Read + as a space when you decode form data or a search query.
When should I encode a value and when a whole URL?
Encode a value when the text will become one piece of a URL, such as a search term or a file name: every reserved character, including /, ?, & and =, is escaped. Encode a whole URL when you already have a complete address that contains spaces or non-English letters: its structure is kept.
Why do I get an error when decoding?
A percent sign must be followed by two hex digits. 100% or %zz is not valid encoding, and the tool tells you where the problem is. You also get an error when the bytes do not form valid UTF-8, for example %E9 on its own.
Why is the result different after decoding and encoding again?
Decoding loses information: after it, you cannot tell which & was a separator and which was %26 inside a value. Encoding the decoded text as a value escapes all of them. Encode values one at a time, before you join them into a URL.
How are letters like é or 日 encoded?
They are first turned into UTF-8 bytes, and each byte is written as a percent escape. é is two bytes, so it becomes %C3%A9; 日 is three and becomes %E6%97%A5.

Sources