HandyBench

URL Encoder & Decoder

Percent-encode and decode URLs.

How to use the URL Encoder & Decoder

  1. 1 Paste a URL or string.
  2. 2 Choose encode or decode (whole URL or component).
  3. 3 Copy the result.

Percent-encoding, as RFC 3986 defines it

A URL may only carry a small set of ASCII characters. Anything else is converted to its UTF-8 bytes, and each byte is written as % followed by two hex digits. The euro sign is three bytes, so it becomes %E2%82%AC, and an emoji such as the grinning face becomes four bytes, %F0%9F%98%80. This tool calls the browser's own encodeURIComponent or encodeURI, depending on one checkbox.

ModeLeft aloneUse it for
Component (checked)A-Z a-z 0-9 - _ . ! ~ * ' ( )One query value or path segment
Whole URL (unchecked)Everything above plus ; , / ? : @ & = + $ #A complete URL that is already structured

Worked example

Input: https://example.com/search?q=hello world&lang=fr#top café

Whole-URL mode gives https://example.com/search?q=hello%20world&lang=fr#top%20caf%C3%A9, so the structure survives and only the space and the accented letter change. Component mode gives https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Dfr%23top%20caf%C3%A9. That is correct for a value you are embedding in another URL, but it breaks a link you wanted to click.

Pitfalls specific to this tool

  • Spaces are always %20. The browser functions never emit +. The plus-for-space convention belongs to HTML form encoding, and on decode a literal + is left as a plus. To read a form-style query string, replace the plus signs with spaces yourself first.
  • Double encoding. Encoding an already-encoded string turns %20 into %2520, because the percent sign itself is encoded. Running Decode twice undoes it.
  • A bare percent sign. Decoding 100% fails with an invalid percent-encoding message, because % must be followed by two hex digits. Encode 50% off first and it becomes 50%25%20off.
  • The checkbox applies in both directions. Decoding in whole-URL mode deliberately leaves sequences such as %2F and %26 encoded, since they stand for reserved characters. Switch to component mode to decode them.
  • Broken emoji. Text containing half of an emoji (an unpaired surrogate) cannot be encoded, and the tool shows an error instead of failing silently. Remove the stray character and try again.
  • The result replaces your text in the same box, so copy the original if you want to compare.

For binary data or tokens that must survive in a URL, see Base64 encode and decode, which solves a different problem.

Examples

  • ▸ Encoding "hello world & café" as a component gives hello%20world%20%26%20caf%C3%A9.
  • ▸ Decoding %E2%82%AC back to the euro sign.
  • ▸ Whole-URL mode keeps https://example.com/a?b=1 intact and only escapes spaces and non-ASCII characters.

Frequently asked questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI keeps URL structure characters like / and ? intact, while encodeURIComponent escapes them too — use the latter for query-string values.

Why does a space become %20 here and + elsewhere?

This tool always writes a space as %20, which is valid in both paths and query strings. The + form comes from HTML form encoding, which some servers and frameworks use. Decoding here leaves a + as a plus sign, so swap plus signs for spaces yourself when reading form-style data.

When do I need URL encoding?

Whenever a value contains characters outside the unreserved set — spaces, &, ?, #, =, / or non-ASCII text — encode it before putting it in a URL so it is not misread as URL structure.

Why did my link turn into %2520?

The text was encoded twice. The first pass turned a space into %20, and the second encoded the percent sign itself as %25. Decode once to get back to the single-encoded form.

Why does encoding say the text contains an unpaired surrogate?

Emoji and some rare characters are stored as two UTF-16 halves. If one half is missing, for example from a copy that cut an emoji in two, the text cannot be turned into valid UTF-8 bytes. Delete or retype the broken character and encode again.

Why do I get an invalid percent-encoding error?

A % must be followed by two hex digits. A literal percent sign, as in 100%, makes decoding fail. Encode the text first, so the sign becomes %25, or fix the stray % by hand.