OmniFeed Search

URL encoder / decoder

The encoder percent-encodes text exactly the way JavaScript's encodeURIComponent does and decodes it back, leaving only letters, digits, and - _ . ! ~ * ' ( ) as they are. Paste a full URL and you'll also see its parts and query parameters. It runs in your browser; nothing you enter is uploaded.

How percent-encoding works

When a character has to be encoded, the encoder takes its UTF-8 bytes and writes each byte as % followed by two hex digits. A space becomes %20, & becomes %26, and ë, which is two bytes in UTF-8, becomes %C3%AB. So name=Zoë & co encodes to name%3DZo%C3%AB%20%26%20co, and Decode turns it back.

RFC 3986 sets the rules, and it leaves letters, digits, and - . _ ~ unencoded. encodeURIComponent also leaves ! ' ( ) * alone. If you're signing requests for OAuth 1.0 or AWS Signature Version 4, which use strict RFC 3986 encoding, those five have to be %21 %27 %28 %29 %2A, so replace them yourself before you sign.

Encode each value, not the whole URL

The encoder is meant for one value, such as a single query parameter. It encodes : / ? & = # too, so if you paste a whole URL, https://a.com/ turns into https%3A%2F%2Fa.com%2F. To build a URL, encode each value on its own and join the values with unencoded separators.

JavaScript's encodeURI is meant for a whole URL and leaves those separators alone. That's why it can't safely encode a value that contains one of them.

The other common mistake is encoding twice. Encode %20 again and you get %2520, so the server receives the text %20 instead of a space.

The plus sign

HTML forms and URLSearchParams use the application/x-www-form-urlencoded format, which writes a space as +. For example, new URLSearchParams({ q: 'a b' }).toString() gives q=a+b. But decodeURIComponent leaves + as it is, so the Read + as a space when decoding box decides what happens to it. Keep the box ticked for query strings and form data. Untick it for other text, where + is a real plus sign.

Reading a URL

When you paste an absolute URL, the encoder splits it with the browser's own URL parser, which follows the WHATWG URL Standard, and decodes each query parameter. A key that appears twice, as in ?tag=x&tag=y, shows as two rows. The port shows as (default) when the URL leaves it out or gives the scheme's usual port, such as 443 for HTTPS. The fragment after # stays in the browser and is never sent to the server.

In other languages

More in encode and decode

Other tools