What the URL Encoder & Decoder does
The tool has an input box on the left and a result box on the right, with Encode and Decode buttons and a Copy button on the result. Encode writes the result of encodeURIComponent to the result box, which leaves only the letters A to Z and a to z, the digits 0 to 9 and the characters - _ . ! ~ * ' ( ) untouched. Everything else, including spaces and the punctuation that has meaning inside a URL, becomes one or more %XX groups: a space becomes %20, an ampersand %26, a slash %2F and a question mark %3F.
Characters outside ASCII are first converted to UTF-8 and then each byte is percent-encoded. The word café becomes caf%C3%A9, the Japanese character 日 becomes %E6%97%A5 and an emoji produces four groups. This is the encoding that browsers themselves use when they send form data and that servers expect in query strings, so the output can be pasted straight after a parameter name and an equals sign.
Decode reverses the process with decodeURIComponent. If the text contains a percent sign that is not followed by two hexadecimal digits, or the decoded bytes do not form valid UTF-8, the tool reports This text contains an invalid percent-encoded sequence rather than returning garbage. A plus sign is left as a plus sign in both directions, which matters for form data and is explained below.
The tool is meant for a single component: a search term, a redirect target, a file name, a value you are about to place in a query string or path segment. It is not meant for a whole URL, which has structure that component encoding deliberately destroys.
How to use it
Paste the value or the encoded text
For encoding, paste the raw value such as a search phrase. For decoding, paste the part of the URL after the equals sign, or any text containing %XX groups.
Press Encode or Decode
The result appears in the box on the right and your input is left as it is. Encode is not idempotent: encoding an already encoded value turns every % into %25, so encode once and decode once.
Copy and place it in the URL
Copy puts the result on the clipboard. Insert an encoded value after the parameter name and =, joining further parameters with & as usual.
Which characters are changed and which are kept
RFC 3986 divides URL characters into unreserved ones, which never need encoding, and reserved ones, which act as delimiters. The unreserved set is letters, digits and - . _ ~. The reserved set includes the general delimiters : / ? # [ ] @ and the sub-delimiters ! $ & ' ( ) * + , ; =. encodeURIComponent escapes all of the general delimiters and most of the sub-delimiters, so a value containing & or = cannot be mistaken for the start of a new parameter.
It leaves ! ' ( ) * unescaped, as the JavaScript specification defines it, even though they are reserved in RFC 3986. Most servers accept them in a query value, but a few frameworks and signature schemes want them encoded too; if you hit one, replace them by hand with %21 %27 %28 %29 %2A. Spaces always become %20, never a plus sign.
- Kept as they are: A-Z a-z 0-9 - _ . ! ~ * ' ( )
- Space: %20
- & = ? / # : @ + , ; $: each becomes a %XX group
- Non-ASCII text: UTF-8 bytes, one %XX group per byte
Encoding a value versus encoding a whole URL
Paste https://example.com/path?id=5 into the encoder and you get https%3A%2F%2Fexample.com%2Fpath%3Fid%3D5. The colon, the slashes, the question mark and the equals sign have all been escaped, so a browser no longer sees a scheme, a host or a query. That is correct behaviour for a component and wrong for a link, which is why this tool encodes values and not addresses.
A whole URL is the right thing to encode in exactly one situation: when it is itself a value, such as a return address in a redirect parameter. ?next=https%3A%2F%2Fexample.com%2Fpage%3Fid%3D5 is a well-formed query whose single value decodes back to the original address. For a URL you intend to use as a link, encode each query value separately and assemble the URL around them, or use encodeURI in your own code, which keeps the delimiters and escapes only spaces and non-ASCII characters.
Why decoding can fail, and what the plus sign means
decodeURIComponent throws when a percent sign is not followed by two hexadecimal digits, as in 100% or a value cut off mid-sequence, and when the decoded bytes are not valid UTF-8. The second case is common with older systems that encoded text in Latin-1: a French é sent as %E9 is a single byte that is not valid UTF-8 on its own, so it is reported as invalid here. Those values need decoding in a tool that lets you choose the character set.
Form submissions encoded as application/x-www-form-urlencoded, which is what an HTML form sends by default, write a space as a plus sign. That rule belongs to form encoding, not to percent-encoding in general, and this tool does not apply it. If you are decoding a query string copied from a form submission, replace each + with %20 before pressing Decode, or the pluses will survive as literal plus signs.
Limits to know before you rely on it
- The tool encodes a single component. Paste a complete URL and its scheme, slashes and query separators are escaped too, which breaks the link.
- Plus signs are left unchanged in both directions. Form-encoded query strings that use + for spaces need the + replaced with %20 before decoding.
- Decoding assumes UTF-8. Percent-encoded bytes from Latin-1 or other legacy encodings produce the invalid-sequence error instead of readable text.
- The characters ! ' ( ) * and ~ are not escaped, following the JavaScript definition of encodeURIComponent; a few servers want them encoded as well.
- There is no encodeURI mode that keeps a URL's structure while escaping only spaces and non-ASCII characters.
- Pressing Encode more than once double-encodes the text; each pass turns every % into %25.
Questions people ask about the URL Encoder & Decoder
Should I paste my whole URL into the encoder?
Only if the URL is going to be a value inside another URL, such as a redirect target. For a link you want to use as a link, encode the individual query values and build the address around them. Encoding the whole thing escapes the colon, slashes and question mark and the result no longer works as an address.
Why does a space become %20 and not a plus sign?
Because %20 is the percent-encoding of a space under RFC 3986 and is valid everywhere in a URL. The plus sign stands for a space only inside form-encoded data, a separate convention from the HTML forms specification. Servers that parse query strings as form data accept both, so %20 is the safer choice.
Can it encode Arabic, Chinese or emoji text?
Yes. The text is converted to UTF-8 first and every byte becomes a %XX group, so 日 becomes %E6%97%A5 and a four-byte emoji produces four groups. The output is plain ASCII and can be placed in any URL. Decoding turns it back into the original characters.
Why did Decode say the text has an invalid sequence?
Either a % is not followed by two hexadecimal digits, which happens with a literal percent sign or a value cut off at the end, or the encoded bytes are not UTF-8, as with %E9 from a Latin-1 system. Check the end of the text for a truncated %XX group first; if the text comes from an old application, it probably needs decoding as Latin-1.
Is percent-encoding a way to hide a token or password?
No. It is a reversible transformation that any browser undoes automatically, and the encoded value is written to server logs and browser history as it is. Treat anything in a query string as visible. Use HTTPS to protect data in transit and keep secrets out of URLs altogether.
What is the difference between encodeURI and encodeURIComponent?
encodeURIComponent, used here, escapes every character that has structural meaning in a URL, so the output is safe as one value. encodeURI leaves : / ? # & = and similar delimiters alone and escapes only spaces, quotes and non-ASCII characters, so it is for tidying a whole address without breaking it. Encoding a value with encodeURI would let an ampersand in the value start a new parameter.
Sources and further reading
- RFC 3986, Uniform Resource Identifier (URI): Generic Syntax, section 2: reserved and unreserved characters and the percent-encoding mechanism
- MDN Web Docs, encodeURIComponent(): the exact set of characters left unescaped and the difference from encodeURI()
- MDN Web Docs, decodeURIComponent(): when decoding throws a URIError
- WHATWG URL Standard, application/x-www-form-urlencoded: why a plus sign means a space in form data