πŸ”

URL Encoder/Decoder

Encode and decode URLs and URL components

Last updated

How to Use This Tool

Paste a URL or query string, then encode or decode it so it works correctly in links and APIs.

When Should You Use This Tool?

Use this when spaces, symbols, or non-English characters break a URL or when you’re building query parameters.

See also: Unit Converter, Coin Flip .

What is URL encoding?

URL encoding, also called percent-encoding, replaces characters that are unsafe or have a special meaning in a URL with a % sign followed by two hexadecimal digits for each byte. A space becomes %20, an ampersand becomes %26, and non-ASCII characters are first converted to UTF-8 bytes, so Γ© becomes %C3%A9. This tool encodes text with JavaScript's encodeURIComponent() and decodes it with decodeURIComponent(), the same functions web applications use. By default the decoder also reads + as a space, as HTML forms do.

How do I encode or decode a URL with this tool?

  1. Choose Encode URL or Decode URL in the Operation menu.
  2. Paste the text or the encoded string into the input box.
  3. When decoding, leave Treat + as space when decoding checked for form data and query strings, or uncheck it to keep every + as a literal plus sign.
  4. Click Process to see the result.
  5. Click Copy Result to copy it.

The conversion happens in your browser. If a string cannot be decoded, the tool shows an error message in the result area that points to the problem, and there is no result to copy.

What are the common percent-encoded characters?

This table shows what the encoder produces for characters you are likely to find in query strings and paths:

CharacterEncodedWhy it needs encoding
space%20Spaces are not allowed in URLs
&%26Separates query parameters
=%3DSeparates a parameter name from its value
?%3FStarts the query string
#%23Starts the fragment, so the rest is never sent to the server
/%2FSeparates path segments
+%2BRead as a space by form decoders, including this tool by default
%%25Starts every encoded sequence
:%3ASeparates the scheme and the port
@%40Separates user info from the host
, and ;%2C and %3BReserved delimiters
", <, >%22, %3C, %3ENot allowed in URLs
Γ©%C3%A9Non-ASCII, encoded as two UTF-8 bytes
€%E2%82%ACNon-ASCII, three UTF-8 bytes
πŸ˜€%F0%9F%98%80Emoji, four UTF-8 bytes

Letters, digits and the characters - _ . ! ~ * ' ( ) are left unchanged.

Should I encode the whole URL or only the parameters?

Encode each query parameter value (or path segment) on its own, then put the URL together. Encoding the whole URL also encodes the ://, /, ? and = that give the URL its structure, and the result no longer works as a link:

Value:        rock & roll/jazz
Encoded:      rock%20%26%20roll%2Fjazz
Correct URL:  https://example.com/search?q=rock%20%26%20roll%2Fjazz

Whole URL encoded (broken):
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Drock%20%26%20roll

Leaving the value unencoded is just as bad. In ?q=rock & roll the server sees & as the start of a new parameter, so q only receives "rock ".

Why does a space become %20 and not +?

This tool uses encodeURIComponent(), which always encodes a space as %20. The + form comes from HTML form encoding (application/x-www-form-urlencoded), which browsers use when submitting forms and which URLSearchParams produces. Most servers accept both in a query string.

Decoding accepts both. With Treat + as space when decoding checked (the default), a+b%20c decodes to a b c, which is what a server does with a submitted form. Uncheck it to decode only percent sequences, and a+b%20c decodes to a+b c. Leave it unchecked for URL paths, where + is a literal plus sign. A real plus sign, such as in a phone number, should be sent as %2B, which always decodes to +.

What is the difference between encodeURI and encodeURIComponent?

encodeURIComponent(), which this tool uses, encodes every reserved character and is meant for single values. encodeURI() leaves URL structure characters alone and is meant for a complete URL that only needs spaces and non-ASCII characters fixed.

CharacterencodeURIComponent (this tool)encodeURI
&%26&
/%2F/
?%3F?
#%23#
=%3D=
:%3A:
space%20%20
Γ©%C3%A9%C3%A9

How do I URL encode in other languages?

These are the closest equivalents to this tool. They agree on spaces and reserved characters, though a few differ on rare characters such as ! * ' ( ):

// JavaScript
encodeURIComponent("rock & roll")        // rock%20%26%20roll

# Python
urllib.parse.quote("rock & roll", safe="")  # rock%20%26%20roll

// PHP
rawurlencode("rock & roll");            // rock%20%26%20roll

// Java (uses + for spaces, like form encoding)
URLEncoder.encode("rock & roll", StandardCharsets.UTF_8)  // rock+%26+roll

Why does decoding fail with an error?

Decoding fails when a % is not followed by two hex digits, or when the bytes do not form valid UTF-8. A literal percent sign, as in 100%, should have been encoded as 100%25. Old systems sometimes encoded Γ© as %E9 (Latin-1) instead of %C3%A9, and decodeURIComponent() rejects that as well. The error message names the part that failed: for 100% it points to the lone %, and for %E9 it explains that the UTF-8 form of Γ© is %C3%A9.

Frequently Asked Questions

What's the difference between encodeURI and encodeURIComponent?
This tool uses encodeURIComponent, which encodes all reserved characters including / ? # & = and :. encodeURI leaves those characters alone because they form the structure of a URL. Use encodeURIComponent for query parameter values and path segments, and encodeURI only for a complete URL.
Why do I need to encode URLs?
Characters such as spaces, &, = and # either are not allowed in URLs or change how the URL is read. An unencoded & inside a value starts a new parameter, and an unencoded # cuts off everything after it. Encoding makes the value arrive exactly as written.
Can I encode entire URLs?
You can, but the result will not work as a link because :, / and ? are encoded too. Encode only the query parameter values or path segments, then assemble the URL. Encoding a full URL is only correct when you pass it as a parameter inside another URL, such as a redirect target.
What happens if I decode invalid encoded text?
The tool shows an error message in the result area instead of a partial result, and clears the previous result so you cannot copy it by mistake. This happens when a % is not followed by two hex digits, as in 100%, or when the sequence is not valid UTF-8, such as the Latin-1 style %E9.
Does it handle Unicode characters?
Yes. Non-ASCII characters are converted to UTF-8 bytes and each byte is percent-encoded, so Γ© becomes %C3%A9 and an emoji becomes four encoded bytes. Decoding restores the original characters.
Does the decoder turn + into a space?
Yes, by default. With Treat + as space when decoding checked, a+b%20c decodes to a b c, matching HTML form encoding. Uncheck the option to keep + as a literal plus sign, which is correct for URL paths. An encoded plus sign, %2B, always decodes to +.
Why does my URL contain %2520?
%2520 means the text was encoded twice: a space became %20, and then the % was encoded again as %25. Decode it once to get %20 and a second time to get the space, then fix the code that encodes the value twice.
Is a space %20 or + in a URL?
Both are used. %20 is valid anywhere in a URL and is what this tool produces. + means a space only in query strings that use HTML form encoding. In a path, + is a literal plus sign, so %20 is the safer choice. When decoding, this tool reads + as a space unless you uncheck Treat + as space when decoding.