URL Encoding Explained: What %20, %3D and %26 Mean

Why URLs need percent-encoding, which characters are reserved, when to encode a whole URL versus a single query value, and how plus signs and double encoding break links.

By Utkarsh Garg · 2026-11-03 · 5 min read

Why URLs are encoded

A URL can only safely carry a limited set of characters: letters, digits and a few symbols such as hyphen, underscore, dot and tilde. Anything else, including spaces, accented letters, emoji and symbols that have a special job in a URL, must be written as a percent sign followed by two hexadecimal digits. This is called percent-encoding. A space becomes %20, an equals sign becomes %3D and an ampersand becomes %26.

Reserved characters

Some characters have a meaning inside a URL. A question mark starts the query string, an ampersand separates parameters, an equals sign joins a name to a value, a hash starts the fragment and a slash separates path segments. If one of these appears inside a value, it has to be encoded or the URL will be read the wrong way.

For example, in a search for tea & coffee, the ampersand must be written as %26. Otherwise the server sees the query q=tea and a new, empty parameter named coffee.

Common characters and their encoded form

This table lists the characters you will meet most often. The encoded form is what component mode produces. Letters, digits, hyphen, underscore, dot and tilde are never encoded.

Frequently encoded characters
CharacterEncodedWhy it matters
Space%20Cannot appear in a URL at all
Ampersand &%26Separates query parameters
Equals =%3DJoins a name to its value
Plus +%2BMeans a space in form-encoded queries
Question mark ?%3FStarts the query string
Hash #%23Starts the fragment, which is never sent to the server
Slash /%2FSeparates path segments
Percent %%25Starts every encoded sequence, so it must be encoded itself

Encode a component or a full URL

There are two common cases, and they need different treatment.

  • Component mode encodes everything that is not safe, including slashes, question marks and ampersands. Use it for a single value that will be placed inside a URL, such as a search term or a redirect address passed as a parameter. In JavaScript this is encodeURIComponent.
  • Full URL mode leaves the structural characters alone and only encodes what cannot appear anywhere in a URL, such as spaces and non-English letters. Use it when you already have a complete address. In JavaScript this is encodeURI.

Spaces: %20 or a plus sign

In a path, a space is always %20. In a query string sent by an HTML form, a space is often written as a plus sign instead. This is a leftover of the form encoding format. The result is that a plus in a query may mean a space or a real plus, depending on who reads it.

When decoding query strings that came from a form, turn on the option to treat plus as space. When decoding anything else, leave it off. A real plus sign that you want to keep should be written as %2B.

Non-English text

Characters outside basic English are first turned into UTF-8 bytes, and each byte is then percent-encoded. The letter e with an acute accent becomes %C3%A9 because it takes two bytes. A single emoji can take twelve or more encoded characters. This is normal, and a decoder will turn it back into the original text.

Double encoding and other problems

Double encoding happens when an already encoded value is encoded again. The percent sign itself becomes %25, so %20 turns into %2520. If a link shows %2520 or %253D in the address bar, something encoded it twice. Decode once and compare the result.

Other common problems are encoding a whole URL in component mode, which breaks the slashes and the colon after https, and forgetting to encode a value that contains an ampersand. When a link behaves strangely, paste it into the decoder, read the plain text, and check each parameter on its own.

Worked example: a search term with several special characters

Take the search text tea & coffee/100% pure? and build the URL https://example.com/search?q= followed by that text. Here is the process step by step.

  • Choose component mode, because the text is a single value that goes inside a query parameter.
  • Each space becomes %20, the ampersand becomes %26, the slash becomes %2F, the percent sign becomes %25 and the question mark becomes %3F.
  • The result is tea%20%26%20coffee%2F100%25%20pure%3F.
  • The final address is https://example.com/search?q=tea%20%26%20coffee%2F100%25%20pure%3F. The server decodes the value once and sees the original text.

Now compare full URL mode on the same text. It leaves the ampersand, slash and question mark alone and encodes only the spaces and the percent sign, giving tea%20&%20coffee/100%25%20pure?. The query would then be cut at the ampersand and the question mark would be read as structure. This is why a value must always be encoded in component mode.

Passing a URL inside a URL

A redirect or return address is a common case where one URL sits inside another. Suppose a login page takes a parameter named next, and you want it to send people to https://shop.example/cart?id=7&ref=mail. If you paste that address in as it is, the ampersand ends the next parameter and ref=mail is read as a separate parameter of the login page.

Encode the inner address in component mode first: https%3A%2F%2Fshop.example%2Fcart%3Fid%3D7%26ref%3Dmail. Then attach it, as in https://login.example/?next=https%3A%2F%2Fshop.example%2Fcart%3Fid%3D7%26ref%3Dmail. The login page decodes next once and gets the full inner address back, including both of its parameters.

Frequently asked questions

  • Why does my link show %20 instead of a space? A space is not allowed in a URL, so browsers and tools write it as %20. The server turns it back into a space when it reads the request.
  • What is the difference between encodeURI and encodeURIComponent? encodeURI keeps characters such as slash, question mark, ampersand and equals so that a whole address stays intact. encodeURIComponent encodes them, which is what you want for a single value.
  • Why do I see %2520 in a link? The link was encoded twice. The first pass turned a space into %20 and the second pass turned its percent sign into %25. Decode once to get back to the correct form.
  • Is percent-encoding a form of encryption? No. Anyone can decode it, so never use it to hide a password or token. It only makes text safe to carry inside a URL.
  • Should I encode the whole URL before sharing it? Usually not. A normal address is already valid, and encoding it fully breaks the colon and slashes. Encode only the values that you insert into it.