English

URL Encode / Decode

Encode text containing non-ASCII characters or symbols into a form you can use in a URL (such as %E6%A4%9C), or decode encoded text back to the original. UTF-8, Shift_JIS, and EUC-JP are supported, and the charset is detected automatically when decoding.

Everything is converted in your browser. Your input is never sent to a server.

Conversion
Symbols to leave unencoded

Letters and digits are never encoded. Changing a checkbox switches the method to “Custom”.

Spaces

Examples:

What is URL encoding?

Only letters, digits, and a few symbols can be used as-is in a URL. To put other characters, spaces, or symbols that separate parts of a URL (such as ? and &) into a URL, the text is converted to bytes and each byte is written as “%” followed by two hexadecimal digits. This is called URL encoding (percent-encoding).

For example, “検索” (Japanese for “search”) is the six bytes E6 A4 9C E7 B4 A2 in UTF-8, so it is encoded as %E6%A4%9C%E7%B4%A2. Decoding does the reverse: it turns each %XX back into a byte and reads the bytes as characters in the charset.

Differences between methods

Which symbols are left unencoded depends on where the text is used and which function you use. Letters and digits are left as-is by every method.

MethodSymbols left unencodedSpaces (default)
RFC 3986 (rawurlencode)

Leaves only the symbols that the URL standard (RFC 3986) says never need encoding. The safest choice: the meaning does not change wherever you put the result.

- . _ ~%20
encodeURIComponent

Same as JavaScript encodeURIComponent. Use it for text that goes into part of a URL, such as a query value (after ?q=).

- . _ ~ ! * ' ( )%20
encodeURI (whole URL)

Same as JavaScript encodeURI. Leaves symbols that separate parts of a URL, such as : / ? # & =, so use it to encode a whole URL.

- . _ ~ ! * ' ( ) ; , / ? : @ & = + $ #%20
Form submission (application/x-www-form-urlencoded)

Same as submitting an HTML form (application/x-www-form-urlencoded). Spaces become +.

- . _ *+
PHP urlencode

Same as PHP urlencode. ~ is also encoded, and spaces become +.

- . _+

%20 vs. + for spaces

In the URL standard, a space is %20. When an HTML form is submitted (application/x-www-form-urlencoded), however, spaces are written as +.

So whether + means a space depends on where it appears in the URL. Select “Treat + as a space” when decoding a query string, but not for paths and other parts.

Differences between charsets

The same character is a different sequence of bytes in each charset, so the encoded result also differs. Encoding “検索” gives the following. UTF-8 is the standard on today’s web, but Shift_JIS and EUC-JP are still used by older systems and some Japanese sites.

CharsetEncoded result
UTF-8%E6%A4%9C%E7%B4%A2
Shift_JIS (CP932)%8C%9F%8D%F5
EUC-JP%B8%A1%BA%F7

Functions in each programming language

Common functions in major languages, and the settings in this tool that give the same result (with the UTF-8 charset). Each language differs in which symbols it leaves and how it handles spaces.

LanguageFunctionMethodSpaces
JavaScriptencodeURIComponent()encodeURIComponent%20
JavaScriptencodeURI()encodeURI (whole URL)%20
JavaScriptURLSearchParamsForm submission (application/x-www-form-urlencoded)+
PHPrawurlencode()RFC 3986 (rawurlencode)%20
PHPurlencode()PHP urlencode+
Pythonurllib.parse.quote(s, safe='')RFC 3986 (rawurlencode)%20
Pythonurllib.parse.quote_plus()RFC 3986 (rawurlencode)+
JavaURLEncoder.encode()Form submission (application/x-www-form-urlencoded)+
Gourl.QueryEscape()RFC 3986 (rawurlencode)+
RubyERB::Util.url_encode()RFC 3986 (rawurlencode)%20
RubyURI.encode_www_form_component()Form submission (application/x-www-form-urlencoded)+
C#Uri.EscapeDataString()RFC 3986 (rawurlencode)%20

How to use

  1. Choose “Encode” or “Decode”.
  2. Choose a charset. When decoding, “Auto-detect” picks UTF-8, Shift_JIS, or EUC-JP for you.
  3. When encoding, choose the method and how to handle spaces. When decoding, choose whether to treat + as a space.
  4. Type text in the input box and the result appears immediately. Use “Copy” to copy the result.

Frequently asked questions

Is my input sent to a server?

No. All conversion happens in your browser, and your input is not saved.

The decoded text is garbled.

The text may have been encoded in a different charset than the one you are decoding with. Try “Auto-detect”, or choose Shift_JIS or EUC-JP.

It says some characters cannot be converted to Shift_JIS.

Characters that do not exist in Shift_JIS or EUC-JP, such as emoji, cannot be converted. Shift_JIS in this tool is CP932, the variant used on Windows, so vendor-specific characters such as ① and ㈱ can be converted. The wave dash (〜 U+301C) is not in CP932, so replace it with the fullwidth tilde (~ U+FF5E).

When should I use encodeURIComponent or encodeURI?

Use encodeURIComponent for text that goes into part of a URL, such as a query value. encodeURI leaves : / ? & = and so on, so it is for a whole URL—but note that & and = inside values are not encoded either.

It says “% is not followed by two hexadecimal digits”.

The text to decode contains a % that is cut off, such as %E3%8. Check that part of the URL was not lost when you copied it, and that % is not being used as a literal character.

Can I decode text that was encoded twice?

If the text contains %25, as in %25E6, it may have been encoded twice. Swap the result into the input and decode it again.