What is URL encoding?
A URL may only contain a limited set of ASCII characters. Anything else — spaces, accented letters, emoji, or characters with a special meaning such as &, = and # — must be converted to bytes and written as % followed by two hexadecimal digits. This is called URL encoding or percent-encoding (RFC 3986).
| Character | Encoded (UTF-8) |
|---|---|
| space | %20 (or + in form data) |
& | %26 |
= | %3D |
/ | %2F |
| é | %C3%A9 |
| 😀 | %F0%9F%98%80 |
encodeURIComponent vs encodeURI
encodeURIComponent also encodes reserved characters such as / ? & = : #. Use it for a single query parameter value, so that an & inside the value does not start a new parameter.
encodeURI keeps the characters that give a URL its structure and only encodes the rest. Use it when you have a complete URL that just contains spaces or non-ASCII characters.
Strict RFC 3986 additionally encodes ! * ' ( ), leaving only unreserved characters (letters, digits and - _ . ~). Some APIs, such as OAuth 1.0 signatures, require this.
Encoding in code
| Language | Encode | Decode |
|---|---|---|
| JavaScript | encodeURIComponent(s) | decodeURIComponent(s) |
| Python | urllib.parse.quote(s, safe='') | urllib.parse.unquote(s) |
| PHP | rawurlencode($s) | rawurldecode($s) |
| Java | URLEncoder.encode(s, UTF_8) | URLDecoder.decode(s, UTF_8) |
| Go | url.QueryEscape(s) | url.QueryUnescape(s) |
Note that Java's URLEncoder, Go's QueryEscape and Python's quote_plus encode spaces as +, following the HTML form format.
Frequently asked questions
Is my input sent anywhere?
No. The conversion runs entirely in your browser with JavaScript. Nothing you type is uploaded, logged or stored, so it is safe to paste internal URLs or tokens.
Should a space be %20 or +?
Use %20 in the path of a URL. A + means a space only in HTML form data (application/x-www-form-urlencoded). Turn on “Space as +” to produce or decode the form format.
How do I fix a double-encoded URL?
If you see %25 (an encoded %), the text was encoded twice — for example %2520 instead of %20. Decode it, click “Use result as input”, and decode again.
Why is there a Shift_JIS option?
Some older Japanese websites encode URLs in Shift_JIS or EUC-JP instead of UTF-8. If decoding produces garbled characters, try switching the charset.