Skip to content
AgileLogics

URL Encoder

Encodes reserved and non-ASCII characters using percent-encoding (via encodeURIComponent), so the result can be safely used in a URL query string or path segment.

How it works

Type or paste text into the input panel and click Encode.

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

  1. Type or paste the text you want to put in a URL, such as a single query value.
  2. Click Encode.
  3. 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

Frequently asked questions

Why are slashes, colons and question marks encoded too?
This tool encodes a single component, such as one query value, so characters that have a structural meaning in a URL are escaped. If you paste a whole URL, https:// becomes https%3A%2F%2F. Encode only the parts that contain user data, then assemble the URL.
Does it encode spaces as + or %20?
As %20. The + form comes from HTML form encoding (application/x-www-form-urlencoded) and is only understood as a space in query strings. %20 works everywhere in a URL.
Which characters are left unchanged?
Letters A-Z and a-z, digits 0-9, and the nine characters - _ . ! ~ * ' ( ). Everything else, including spaces, &, =, /, ?, # and %, is percent-encoded.
How are non-English characters encoded?
Each character is converted to its UTF-8 bytes, and each byte becomes a %XX escape. "é" becomes %C3%A9 and a thumbs-up emoji becomes %F0%9F%91%8D, which is what browsers and servers expect.
Is my text sent to a server?
No. Encoding uses JavaScript's built-in encodeURIComponent in your browser.