Back to All Tools

URL Encoder / Decoder

Encode or decode URL strings instantly.

100% Private — Your data never leaves your browser. Everything runs locally on your device.

Using the encoder and decoder

  1. Paste text into the Input box. This is usually one value that will go into a URL, such as a search term or a file name.
  2. Encode changes special characters into %XX codes. It uses the browser's encodeURIComponent() function.
  3. Decode changes %XX codes back into characters. It uses decodeURIComponent().
  4. Treat + as space is off by default. Turn it on before you press Decode when the text came from an HTML form or a query string. Then every + becomes a space.
  5. Copy copies the Output box. The button reads Copied! for a moment when it works.

If Encode or Decode fails, a message under the buttons says why, and the Output box is cleared. So you cannot copy an old result by mistake. Encode fails only in one rare case: the text has a broken character, such as half of an emoji copied from another program.

What Encode changes: a worked example

Encode the text a b&c=d/é and you get:

a%20b%26c%3Dd%2F%C3%A9

Each special character became a % sign and two hex digits. Characters outside English, like é, are first turned into UTF-8 bytes. Then each byte gets its own code. é is two bytes, so it becomes %C3%A9.

CharacterEncodedWhy it matters in a URL
space%20A URL cannot contain a real space.
&%26Separates query parameters.
=%3DSeparates a parameter name from its value.
?%3FStarts the query string.
#%23Starts the fragment. The browser does not send it to the server.
/%2FSeparates path parts.
+%2BMany servers read a plain + in a query as a space.
%%25Starts every code, so it must be encoded itself.
नमस्ते%E0%A4%A8%E0%A4%AE...6 characters, 18 UTF-8 bytes, 54 characters when encoded.
😀%F0%9F%98%804 UTF-8 bytes.

Encode leaves these characters as they are: A-Z a-z 0-9 - _ . ~ ! ' ( ) *.

The last five (! ' ( ) *) are a known gap in encodeURIComponent. They are safe in most URLs. But a few strict systems, such as OAuth 1.0 signatures, need them encoded as well. In JavaScript you can add this step yourself:

encodeURIComponent(text).replace(/[!'()*]/g,
  c => '%' + c.charCodeAt(0).toString(16).toUpperCase())

Encode one value, not the whole URL

This tool encodes everything that has a meaning in a URL, including :, /, ? and &. That is exactly right for a single value. It is wrong for a full address. Paste a full URL and you get this:

Input:  https://example.com/search?q=red shoes&page=2
Output: https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dred%20shoes%26page%3D2

That output no longer works as a link. Instead, encode only the value and put it into the URL yourself. For the search term red shoes & socks:

Value:   red shoes & socks
Encoded: red%20shoes%20%26%20socks
URL:     https://example.com/search?q=red%20shoes%20%26%20socks&page=2

If you did not encode the value, the & would end the q parameter. The server would read q as red shoes and treat socks as a separate, empty parameter.

JavaScript has a second function, encodeURI(), for full URLs. It keeps : / ? & = # and only encodes things like spaces and non-English letters. This tool does not offer it. In the example above, encodeURI would give https://example.com/search?q=red%20shoes&page=2.

Decoding: plus signs and errors

By default, a plus sign stays a plus sign. decodeURIComponent does not turn + into a space. So red+shoes decodes to red+shoes. But HTML forms and many query strings use + for a space. For that kind of text, turn on Treat + as space. Then red+shoes decodes to red shoes. A real plus sign in form text is written %2B, so it stays correct: a%2Bb+c decodes to a+b c. Leave the option off for other text, such as a path or a Base64 value, where + really means a plus sign.

Broken codes give an error. Decode stops with Invalid encoded string for any of these:

InputProblem
100%A % with nothing after it. A real percent sign must be written %25.
%zzzz is not a hex number.
%E0%A4Only part of a character. The text was cut in the middle of a UTF-8 sequence.
caf%E9Encoded as old Latin-1, not UTF-8. The UTF-8 form is caf%C3%A9.

If one bad code appears anywhere in the input, nothing is decoded. When the problem is a % without two hex digits, the message tells you its position, counting from 1. Fix or remove that part, then try again.

Decode removes one layer at a time. %2520 decodes to %20, not to a space. That means the text was encoded twice. Press Decode again to remove the second layer.

Common mistakes

Frequently Asked Questions

Can Decode turn + into a space?

Yes, if you turn on Treat + as space. It is off by default, because decodeURIComponent only decodes %XX codes and leaves + as it is. HTML forms and many query strings use + for a space, so turn the option on for text from a form or a query string. A real plus sign in that text is written %2B, so it stays a plus.

Why do I get Invalid encoded string?

The input has a % that is not followed by two hex digits, such as 100% or %zz. Or it has a broken or non-UTF-8 byte sequence, such as caf%E9. One bad code stops the whole decode. The message shows where the first bad % is, so fix or remove it and try again.

Can I paste a full URL into the encoder?

You can, but the result will not work as a link. The tool encodes : / ? and the other URL characters too, so https:// becomes https%3A%2F%2F. Encode only the value you put into the URL, such as a search term.

Which characters does Encode leave unchanged?

Letters A to Z and a to z, digits, and the characters - _ . ~ ! ' ( ) *. Everything else, including spaces and all non-English letters, is turned into %XX codes of its UTF-8 bytes.

Is URL encoding the same as Base64?

No. URL encoding keeps normal letters and digits as they are and only changes special characters into %XX codes. Base64 rewrites all of the data into a 64-character alphabet. Neither one is encryption.

Is my text sent to a server?

No. Encoding and decoding use the encodeURIComponent and decodeURIComponent functions built into your browser, and the page does not send your text anywhere.