URL encoder and decoder

Type in either box to encode or decode as you go.

What URL encoding does

A web address may only contain a small set of characters: the letters A to Z and a to z, the digits, and a few symbols. Everything else, a space, an accented letter, an emoji, has to be written as one or more escapes: a % followed by two hexadecimal digits, one per byte of the character in UTF-8. That is percent-encoding, defined in RFC 3986. A space is byte 20, so it becomes %20; ñ is the two bytes C3 B1, so it becomes %C3%B1.

Some symbols have a job in a URL: / separates the path, ? starts the query, & separates parameters, = joins a name to its value, # starts the fragment. When one of them is part of a value, it must be encoded too, or it will be read as structure. That is why this tool asks what you are encoding.

A value or a whole URL

“A value” is for one piece that goes inside a URL: a search term, a file name, a parameter. It keeps only the letters, the digits and - . _ ~, the characters RFC 3986 calls unreserved, and encodes everything else, including / ? & = #. It also encodes ! ' ( ) *, which JavaScript’s encodeURIComponent leaves alone; RFC 3986 reserves them, and encoding them is always safe. Decoding reads both forms.

“A whole URL” is for an address you already have and want to make valid. It works like JavaScript’s encodeURI: it encodes spaces and non-ASCII letters but keeps : / ? # & = so the address still works.

InputA valueA whole URL
café con leche & pancaf%C3%A9%20con%20leche%20%26%20pancaf%C3%A9%20con%20leche%20&%20pan
https://example.com/?q=1https%3A%2F%2Fexample.com%2F%3Fq%3D1https://example.com/?q=1
€%E2%82%AC%E2%82%AC
😀%F0%9F%98%80%F0%9F%98%80

Under the result, a table lists each character that was encoded with its UTF-8 bytes, so you can see why € takes three escapes and an emoji four. When the text is a full web address, the tool also splits it into its parts and lists every query parameter, decoded.

Reserved and unreserved characters

KindCharactersIn a value
UnreservedA–Z a–z 0–9 - . _ ~Never encoded
Reserved, structure: / ? # [ ] @Encoded
Reserved, separators! $ & ' ( ) * + , ; =Encoded
Everything elsespace, %, ", <, >, accented letters, emoji…Always encoded

Spaces: %20 or +

HTML forms send their fields in a slightly different format, application/x-www-form-urlencoded, where a space is written + instead of %20. Both are common in query strings. With “Spaces as +” ticked, the tool writes spaces as + and reads + back as a space; a real plus sign is then written %2B, otherwise it would come back as a space. Without the option, a + is left as a +.

Libraries differ here. PHP’s urlencode writes + for spaces and rawurlencode writes %20; Python’s quote writes %20 but by default leaves / unencoded, while quote_plus writes +. If a server reads + as a plus sign, a value sent with + for spaces arrives with plus signs in it.

Mistakes that break links

  • Encoding a whole URL as a value: as in the table above, every / : and ? is escaped and the result, starting https%3A%2F%2F, is no longer a link. That is right only when the URL is itself the value of a parameter, such as a redirect address.
  • Encoding a value as a whole URL: “fish & chips” becomes fish%20&%20chips, and the & splits it, so the server receives q = “fish ” and a second parameter called “ chips”. Encoded as a value it is fish%20%26%20chips.
  • Encoding twice: % is not a safe character, so encoding a text that is already encoded turns %20 into %2520. If you see %25 followed by two hex digits, decode once more. The tool warns when the text you encode already has escapes, and when a decoded text still does.
  • Using an old character set: before UTF-8 became the rule, é was often sent as %E9 (Latin-1). That is not valid UTF-8, and the tool says what the bytes mean in Latin-1 so you can recognize it.

Questions

Why does ñ turn into %C3%B1 and not a single escape?

Because URLs carry bytes, and in UTF-8, the encoding the web uses, ñ is two bytes, C3 and B1. Letters with accents take two bytes, the euro sign three, and an emoji four.

How are domain names with accents encoded?

Not with percent escapes. A name like münchen.de is converted with Punycode to xn--mnchen-3ya.de, which is what browsers and DNS actually use. When a URL has such a name, the parts table shows both forms.

Is URL encoding a way to hide or protect data?

No. Anyone can decode it, as this page does. To put binary data or a token in a URL, Base64 in its URL-safe form is shorter; see the Base64 encoder. Neither one is encryption.

Is what I paste sent anywhere?

No. Encoding, decoding and the URL breakdown all happen in your browser. The address is read by the browser’s own parser and is never opened.

More encoding and conversion tools

See all tools