Guides / Files and data guides

URL Encoding Explained: Percent Codes, %20 and Query Strings

Written by the convertalldoc team. Updated

A web address can only contain a limited set of characters. Spaces, accents and symbols such as & or # have to be written as a percent sign followed by two hexadecimal digits. A space becomes %20, for example. This is called URL encoding, or percent encoding. To do it now, open URL Encode and Decode, paste your text, choose encode or decode, and copy the result.

How to encode or decode a URL

  1. Open URL Encode and Decode.
  2. Choose Encode or Decode.
  3. Paste your text or web address into the input box.
  4. For encoding, choose how to encode: Component (encodeURIComponent) or Whole URL (encodeURI). The next section explains which to pick.
  5. Copy the result. If your text contains a query string, a table of names and values appears underneath.

There is also a button to use the result as the new input, which switches the mode for you. It is handy for checking that encoding then decoding gives back what you started with.

Value or whole URL?

There are two ways to encode, and picking the wrong one is the most common mistake.

A worked example

Say you want to build a link to a search page, and the search phrase is: rock & roll / 50% off. If you encode the phrase as a component, every special character is converted, so the ampersand, the slash and the percent sign cannot be mistaken for structure. You then add the encoded phrase after q= in your link.

If you instead used Whole URL on that phrase, the ampersand and the slash would be left as they are, and the server would read the phrase as several separate parts. The rule of thumb: encode each value as a component, then assemble the URL around it. Use Whole URL only when you already have a finished address that just needs its spaces and accents fixed.

Why encoding is needed

Some characters have a job in a URL. A question mark starts the query, an ampersand separates one parameter from the next, an equals sign joins a name to its value, a slash separates path segments and a hash starts a fragment. If your data contains one of those characters, it must be encoded so it is read as data and not as part of the structure. Encoding also lets you include characters that are not allowed at all, such as spaces, and non-English letters.

Common examples

Space: %20 or plus?

This causes real confusion. The code %20 means a space everywhere, so it is the safest choice. A plus sign means a space only in form-style query strings, the kind produced by older HTML forms. In a path, a plus is just a plus.

The tool has a tick box for this. When encoding, you can choose to write spaces as plus signs. When decoding, you can choose to treat plus signs as spaces. It starts ticked when decoding, since that is what most query strings expect. Untick it if you are decoding a path, or a value where a plus sign is a real plus, such as in a phone number.

Reading a messy link

Long tracking links and redirect addresses are hard to read because the values inside them are encoded. Paste one into the tool and choose Decode. The text turns back into readable characters. If the text contains a question mark and parameters, or is just a string like a=1&b=2, the tool lists each name and value in a table, with a button to copy each value. That makes it easy to see what a link is carrying before you click or share it.

Some points to know about the table:

Double encoding

If you see %2520, the text was encoded twice. The code %25 stands for the percent sign itself, so a %20 that was encoded again becomes %2520. Decode once to get back to %20, and decode again to get the original space. The safest habit is to encode only once, at the last step before the value goes into the address, and to decode only once on the receiving side.

When decoding reports a problem

If a percent code is cut off, such as a lone % at the end, or the bytes are not valid UTF-8, the whole text cannot be decoded in one go. In that case the tool decodes every part it can and leaves the faulty parts as typed, and it tells you so. The usual cause is a link that was truncated when copied, or text that was encoded using an older character set.

When encoding, a broken emoji or symbol, known as an unpaired surrogate, cannot be encoded, and the tool says so. Retype or remove the character.

Practical scenarios

Building a link that contains a person’s name

A name such as Zoe O’Brien and Sons needs encoding if it goes into a query parameter. Encode it as a component, then add it after the parameter name.

Sharing a link with a file name that has spaces

A file called Annual Report 2025.pdf cannot be put in a link as it is. Encoding gives Annual%20Report%202025.pdf. Use Whole URL if you are fixing a complete address, so the slashes stay as they are.

Debugging a form that sends the wrong data

If a value arrives with unexpected plus signs or percent codes, decode it once and look at the result. If it still contains percent codes, it was probably encoded twice.

Putting a web address inside another web address

Redirect links often carry a full address as a parameter. Encode the inner address as a component, so its slashes, question marks and ampersands do not interfere with the outer link.

Checklist for clean links

  1. Encode each value separately, as a component.
  2. Leave the structure characters (? & = and #) unencoded only where they play their structural role.
  3. Prefer %20 for spaces unless you know the receiver expects a plus sign.
  4. Encode once, never twice.
  5. Test the finished link in a browser before you share it.

Related guides

A related but different job is Base64 encoding, which turns binary data into text. If you need to make a link scannable, the QR code guide shows how to turn an address into a code, and it is worth encoding any special characters before you do. For the size of text you are sending, the File Size Converter converts between units.

Which characters never need encoding?

Letters A to Z, digits 0 to 9 and the marks hyphen, underscore, full stop and tilde are always safe in a URL, so they are never changed. Component encoding in the browser also leaves a few extra marks alone: the exclamation mark, asterisk, apostrophe and round brackets. Whole URL encoding additionally leaves the characters that give an address its structure. Everything else, including spaces, quotes, angle brackets, curly brackets and every non-English letter, is converted.

One small detail: when you use Whole URL, the tool leaves square brackets as they are rather than converting them, because some addresses use them in query parameters. If a system you are feeding insists on every bracket being encoded, use Component for that value instead.

Encoding in other places

URL encoding turns up in more places than the address bar.

If you want to see how much text you are adding to an address, remember that each encoded byte takes three characters, so an accented letter takes six. Very long addresses can be refused by some servers, so keep values short where you can. If you are not sure whether a tool that handles your links sends them anywhere, read how to tell if an online converter uploads your files.

Is it security?

No. Encoding does not hide anything. Like Base64, anyone can reverse it in a moment. Do not put passwords or tokens in a link and assume that encoding protects them, because links are often saved in browser history, logs and shared messages.

Privacy

Everything is done in your browser. Links with tokens or personal details are not sent to a server.

Frequently asked questions

What is the difference between encodeURIComponent and encodeURI?

encodeURIComponent encodes everything except letters, digits and a few marks, including / ? & = and #, so it suits a single value. encodeURI keeps those characters, so it suits a complete URL that should stay a working link.

Is my text uploaded?

No. Encoding and decoding use your browser and nothing is sent anywhere.

Should a space be %20 or a plus sign?

%20 works everywhere. A plus sign means a space only in form-style query strings. The tool has an option to write or read spaces as plus signs.

Does it handle non-English characters?

Yes. Characters are encoded as UTF-8, so an accented letter becomes two percent codes, and decoding reverses it.

Why does decoding say some sequences were left as typed?

A percent code that is cut off, or that is not valid UTF-8, cannot be decoded. The tool decodes everything else and leaves those parts unchanged.

How does the query string table work?

If your text is a URL with a question mark part, or a string like a=1&b=2, each name and value is decoded and listed, with a copy button for each value.

What does %2520 mean?

It means the text was encoded twice. The code %25 is the percent sign, so %2520 is an encoded %20. Decode it once to get %20 and again to get a space.

More guides

All guides