calc-hub logocalc-hub.net

URL Encode / Decode

Pick Encode and paste your text to turn every character outside A–Z, a–z, 0–9 and - _ . ! ~ * ' ( ) into %XX codes of its UTF-8 bytes. Pick Decode to turn an encoded string back into plain text. The tool works like JavaScript's encodeURIComponent, so it also encodes / ? : & = and #.

How to use the URL Encode / Decode

  1. Pick Encode or Decode at the top.
  2. Paste or type your text in the Input box.
  3. Press URL Encode or URL Decode. The result appears in the Output box, with a link to copy it.

The URL encoding rules

A–Z a–z 0–9 - _ . ! ~ * ' ( ) stay as they are · · · Every other character → %HH for each byte of its UTF-8 encoding

RFC 3986 lists A–Z, a–z, 0–9 and - . _ ~ as unreserved characters that never need encoding. The tool uses JavaScript's encodeURIComponent, which also leaves ! * ' ( ) unencoded. It writes a space as %20, never as +. When decoding, it turns %HH codes back into characters, in capitals or lowercase, and leaves a + as a plus sign. A % that is not followed by two hex digits gets a message naming its position, and bytes that are not valid UTF-8 get a message naming the codes.

Worked example

"hello world" → "hello%20world". "user@example.com" → "user%40example.com". "café" → "caf%C3%A9". Decoding "caf%C3%A9" gives "café" again. Decoding "100%" gives a message, because that % has no hex digits after it. "100%25" decodes to "100%".

Frequently asked questions

When is URL encoding needed?

When text goes into one part of a URL, such as a query string value or a path segment, and contains spaces, characters like & or = that have a meaning in URLs, or letters outside ASCII. You usually encode by hand when you build URLs in code.

Is a space encoded as %20 or +?

This tool always writes %20. HTML form data (application/x-www-form-urlencoded) writes a space as +, and MDN suggests replacing %20 with + after encodeURIComponent for that format. The decoder here leaves + unchanged, so replace each + with a space before decoding form data.

Does Unicode need special encoding?

The tool converts each character to its UTF-8 bytes and percent-encodes every byte. "京" is three UTF-8 bytes, E4, BA and AC, so it becomes "%E4%BA%AC". Decoding that gives "京" again.

Why do I get a message when I decode?

The input is not valid percent-encoding. Either a % is not followed by two hex digits, as in "50%" or "%ZZ", or the codes are not valid UTF-8, as in "%C3" alone, which starts a two-byte character and stops. The tool shows no output for such text. It does not guess.

Why does the tool encode slashes and colons?

It encodes text as a single URL component, the way encodeURIComponent does, so / ? : @ & = + $ , and # all become %XX codes. That is right for one query value or path segment. If you encode a whole URL this way, its https:// and slashes get encoded too.

We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.