Skip to content

URL Encoder & Decoder - Percent-Encode URLs Online

Plain Text
URL Encoded

Encode or Decode a URL Component

Paste text in Encode mode and every character that is not safe inside a URL component becomes a % followed by two hex digits. A space becomes %20, & becomes %26, and é becomes %C3%A9 (its two UTF-8 bytes). Decode mode reverses it. Results update as you type and nothing is sent to a server.

Encode one piece at a time: a query value, a path segment, or a whole URL that you are passing as a parameter to another URL. For example, to put https://shop.example.com/cart?id=7&ref=mail into a redirect= parameter, encode it to https%3A%2F%2Fshop.example.com%2Fcart%3Fid%3D7%26ref%3Dmail. Without that, the &ref=mail part would be read as a separate parameter of the outer URL.

When decoding a query string copied from an HTML form submission, tick "Treat + as space" so that hello+world becomes hello world. Leave it off for paths and for values produced by encodeURIComponent, where + is a literal plus.

URL Percent-Encoding Table

Each encoded character is a % followed by the hex value of its byte. Non-ASCII characters are first converted to UTF-8, so one character can become two to four %XX groups. The table shows whether each character must be encoded inside a path segment (/files/here/) and inside a query value (?q=here), and what JavaScript's two built-in functions do with it.

Character Encoded In path In query value encodeURI encodeURIComponent
space %20 Yes Yes (or +) Yes Yes
! %21 No No No No
" %22 Yes Yes Yes Yes
# %23 Yes Yes No Yes
$ %24 No Optional No Yes
% %25 Yes Yes Yes Yes
& %26 No Yes No Yes
' %27 No No No No
( ) %28 %29 No No No No
* %2A No No No No
+ %2B No Yes No Yes
, %2C No Optional No Yes
/ %2F Yes, inside a segment No No Yes
: %3A No No No Yes
; %3B Optional Yes No Yes
< > %3C %3E Yes Yes Yes Yes
= %3D No Yes No Yes
? %3F Yes No No Yes
@ %40 No No No Yes
[ ] %5B %5D Yes Yes Yes Yes
\ %5C Yes Yes Yes Yes
^ ` %5E %60 Yes Yes Yes Yes
{ | } %7B %7C %7D Yes Yes Yes Yes
~ - _ . (never encoded) No No No No
é %C3%A9 Yes Yes Yes Yes
€ %E2%82%AC Yes Yes Yes Yes

"Optional" means the character is legal there but some servers or frameworks treat it specially, so encoding it is the safe choice. The unreserved characters A-Z a-z 0-9 - _ . ~ never need encoding anywhere.

encodeURI vs encodeURIComponent

encodeURI is for a complete URL. It leaves the structural characters : / ? # & = + $ , ; @ alone so the URL still works, which means it will not protect a value that contains them. encodeURIComponent is for one piece, such as a single query value or path segment, and encodes all of those characters. For example, encodeURIComponent("a&b=c") gives a%26b%3Dc, while encodeURI returns it unchanged and breaks the query string. This tool uses encodeURIComponent. To split a full URL into parts and edit its parameters, use the URL parser.

Common Problems

  • Double encoding. %2520 in a URL means a %20 was encoded a second time (% became %25). Decode once to see the extra layer, and find the step in your code that encodes an already encoded value.
  • "URI malformed" errors. Decoding fails when a % is not followed by two hex digits, as in 100% or 50%off, or when the bytes are not valid UTF-8. Encode a literal percent sign as %25.
  • Plus signs turning into spaces. A phone number like +6421... sent unencoded in a query string arrives as a space on servers that use form decoding. Encode it as %2B.
  • Characters left alone. encodeURIComponent, which this tool uses, does not encode ! ' ( ) *. They are legal in URLs, but some OAuth 1.0 and AWS signature schemes require them encoded. Replace them by hand with %21 %27 %28 %29 %2A if your API asks for strict RFC 3986 encoding.

Related Tools

Frequently Asked Questions

What is URL encoding (percent-encoding)?
Writing a character as % followed by the hex value of each of its UTF-8 bytes. A space is %20, & is %26 and € is %E2%82%AC. It lets characters that would otherwise end a value or change the URL's structure travel as plain data.
Should a space be %20 or + in a URL?
Use %20 in the path. In a query string both work: + means space only in application/x-www-form-urlencoded data, which is what HTML forms and URLSearchParams produce. When decoding a form-encoded query string, tick "Treat + as space"; a literal plus must be sent as %2B.
What is the difference between encodeURI and encodeURIComponent?
encodeURI is for a whole URL and leaves : / ? # & = + $ , ; @ alone so the URL keeps working. encodeURIComponent is for a single value and encodes those too. This tool uses encodeURIComponent, so encoding a full URL here turns :// into %3A%2F%2F. That is right when the URL is a parameter value, and wrong when you just want a clickable link.
Why do I see %2520 in my URL?
The value was encoded twice. %20 (a space) was encoded again, and its % became %25. Decode once to get %20, then fix the code that encodes an already encoded string.
Why does decoding fail with "URI malformed"?
A % sign is not followed by two hex digits, for example 100% or 50%off, or the decoded bytes are not valid UTF-8. Text with a literal percent sign has to be encoded as %25 before it goes into a URL.