URL Encoder & Decoder

Percent-encode a value or a whole URL, and decode either back. Component mode escapes the delimiters inside a single value. Full-URL mode leaves a URL’s structure alone. Picking the wrong one of those two is the usual reason a link comes out broken.

Which characters have to be encoded

Inside a URL these characters carry structural meaning. Left alone in a value, they end the value early and change what the URL means.

CharacterEncodedWhat it means in a URL
space%20Ends the URL in many parsers
&%26Separates one query parameter from the next
=%3DSeparates a parameter name from its value
?%3FStarts the query string
#%23Starts the fragment; everything after it is never sent to the server
/%2FSeparates path segments
+%2BRead as a space when a query string is parsed
%%25Starts an escape sequence

Letters, digits and - _ . ! ~ * ' ( ) are never encoded. They have no special meaning, so escaping them only makes the URL harder to read.

Component mode or full-URL mode

The two modes differ in one thing: whether the characters above are escaped or preserved. Picking the wrong one is the usual cause of a broken link.

Component mode is for a single value you are about to drop into a URL: a search term, a filename, a redirect target:

hello world & more   →   hello%20world%20%26%20more

Full-URL mode is for a URL that is already a URL. It leaves the structure alone and escapes only what is unsafe:

https://x.com/a b?q=1   →   https://x.com/a%20b?q=1

Run that same URL through component mode and you get a string that is no longer a URL at all:

https%3A%2F%2Fx.com%2Fa%20b%3Fq%3D1

That result is correct, which is exactly what you want when the URL is itself a parameter, as in ?redirect=. It is wrong everywhere else.

Frequently asked questions

What is the difference between the two modes?

Component mode escapes the delimiters (/ ? : @ & = + $ #) so the result is safe to use as a single value. Full-URL mode preserves them, because in a URL those characters define the structure. Encoding a whole URL in component mode breaks it. That is the most common mistake with these two functions.

Why does the decoder sometimes report an error?

decodeURIComponent throws on an incomplete escape such as %E0%A4%A. The tool catches that and tells you, so you can see the input arrived truncated.

Are duplicate query keys preserved?

Yes. ?tag=a&tag=b means something, and putting the parameters into an object or a Map would quietly drop one of them. The breakdown keeps every pair, in order.

Why is a space encoded as %20 and not +?

encodeURIComponent never emits +. That substitution comes from form encoding. Reading a query string is a different job, and there the tool does treat + as a space.