What is URL encoding?
URL encoding, also called percent-encoding, replaces characters that aren't allowed or have a special meaning in a URL with a % followed by two hexadecimal digits. A space becomes %20 and & becomes %26. It's how you safely put arbitrary text, like a search term or a file name, inside a link.
The rules come from RFC 3986, the URI standard. Each %XX is one byte, and for non-ASCII text those bytes are the character's UTF-8 encoding.
How to URL-encode text
- Type or paste the text you want to put in a URL, such as a single query value.
- Click Encode.
- Copy the encoded result and insert it into your URL.
The tool uses JavaScript's encodeURIComponent(), so the output matches what a web app written in JavaScript would produce.
Worked example: building a search link
Say you want to link to a search for fish & chips = 50%. If you paste that into a URL unencoded, the & would start a new parameter, = would confuse the parser, and % would be read as the start of an escape. Encoding the value first gives:
fish%20%26%20chips%20%3D%2050%25
and the final link is safe to use:
https://example.com/search?q=fish%20%26%20chips%20%3D%2050%25
What gets encoded
| Character | Encoded | Why |
|---|---|---|
| space | %20 |
Not allowed in URLs |
& |
%26 |
Separates query parameters |
= |
%3D |
Separates names from values |
? |
%3F |
Starts the query string |
# |
%23 |
Starts the fragment |
/ |
%2F |
Separates path segments |
% |
%25 |
Starts an escape sequence |
é |
%C3%A9 |
Two UTF-8 bytes |
| 👍 | %F0%9F%91%8D |
Four UTF-8 bytes |
Left unchanged: A–Z, a–z, 0–9 and - _ . ! ~ * ' ( ). Note that encodeURIComponent leaves ! ' ( ) * alone, while RFC 3986 lists them as reserved sub-delimiters. That's almost never a problem, but a few strict APIs, such as OAuth 1.0 signature generation (RFC 5849), require them encoded as well.
Don't encode a whole URL
This tool is meant for one piece of a URL at a time. Paste a complete address and every structural character gets escaped:
https://example.com/a b?q=1&r=2#x
becomes
https%3A%2F%2Fexample.com%2Fa%20b%3Fq%3D1%26r%3D2%23x
which no longer works as a link. That output is exactly right, though, when the whole URL is itself a parameter value, as in a redirect like /login?next=https%3A%2F%2Fexample.com%2F.
Also watch out for double encoding. If your text already contains %20, encoding it again turns it into %2520. Decode it first with the URL decoder if you're not sure.
URL encoding vs. similar encodings
- Form encoding (
application/x-www-form-urlencoded), used when HTML forms submit, writes spaces as+. This tool always uses%20, which servers also accept in query strings. - Base64 turns any data into letters and digits but isn't designed for URLs, because standard Base64 contains
+,/and=. - HTML entities like
&escape text for HTML documents, not URLs. A URL inside an HTML attribute may need both.
In your own JavaScript, use encodeURIComponent for individual values, as this tool does, and encodeURI only when you have a complete URL that just needs spaces and non-ASCII characters escaped, since it leaves : / ? # & = intact. You can draft that code in the online JavaScript editor.
Last updated