You copy a link out of a browser address bar and half of it looks like someone leaned on the percent key: rock%20%26%20roll%3F%20live. Nothing is broken and nothing is hidden. That string is percent-encoded, which is how a URL carries characters it was never designed to hold raw, like spaces, ampersands and accented letters.

This guide explains what percent encoding is, why some characters must be encoded and others never need it, and when a URL actually needs it, using the free URL Encoder/Decoder on Ovatly for the worked examples.

Contents

  • Quick answer
  • The basic move: one byte, three characters
  • Reserved characters carry the structure
  • Unreserved characters travel raw
  • Non-ASCII text: bytes first, then percents
  • How to percent-encode text, step by step
  • Worked example: three values encoded
  • Limitations and honest warnings
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Percent encoding is a way of writing a byte inside a URL as a % sign followed by the byte's value in two hexadecimal digits. A space becomes %20, an ampersand becomes %26, a question mark becomes %3F. A URL needs it whenever a character that has a structural job in the address, or no place in an address at all, shows up inside a value the address carries. You can encode or decode any string with the URL Encoder/Decoder: choose Component mode for a single value going into a query string, or Full URL mode for a whole address.

The basic move: one byte, three characters

Every character in a URL is stored and transmitted as one or more bytes, and each byte has a numeric value. Percent encoding takes a byte that cannot safely appear raw and writes it as three characters: the % sign, then the byte's value in hexadecimal, split into two digits.

A space is byte value 32 in decimal, which is 20 in hexadecimal, so a space is written %20. An ampersand is byte 38, hexadecimal 26, so it becomes %26. A slash is byte 47, hexadecimal 2F, so it becomes %2F. That is the whole mechanism. There is no key, no scrambling and no secrecy, just a fixed rule for writing a byte in a form an address can carry.

Decoding is the same rule run backwards: scan for %, read the next two characters as a hexadecimal byte value, put the original byte back. That is why a stray %, or an incomplete sequence like %2, is a real error rather than a cosmetic flaw: the decoder is promised two digits and does not get them. The Ovatly tool reports that as a clear error instead of printing garbage.

Reserved characters carry the structure

A URL is not just a string of text. It is a small structured document, and certain characters are its punctuation. The ? starts the query string. The & separates one query parameter from the next. The = joins a parameter name to its value. The / separates path segments, and : and # have their own jobs.

Those characters are called reserved, because the URL format reserves them for structure. The problem arrives when the same character is also part of the data. Suppose a search phrase is fish & chips. Dropped raw into a query string, the address reads ?q=fish & chips, and every reader treats that & as punctuation: one parameter ends, a new one begins. The data has silently changed the structure.

Encoding is how you tell the address "this ampersand is data, not punctuation". Encoded as %26, the ampersand travels inside the value and is only turned back into & after the structure has been parsed. The same logic applies to ? becoming %3F, = becoming %3D and / becoming %2F when they appear inside a value rather than doing their structural job.

Unreserved characters travel raw

At the other end of the scale sits a small set of characters that have no structural job and are always safe raw: the letters A to Z and a to z, the digits 0 to 9, and four marks, -, _, . and ~. These are the unreserved characters, and they never need encoding.

You can see this in practice. Encoding the text file-name_v2.0~final changes nothing at all, because every character in it is unreserved. Most of a typical URL is unreserved characters, which is why ordinary addresses stay readable and only the awkward values grow percent sequences.

Between the two groups sits everything else: spaces, stray punctuation, and all non-ASCII text. Those are the bytes percent encoding exists for.

Non-ASCII text: bytes first, then percents

Percent encoding works on bytes, and characters outside plain ASCII are more than one byte. Text is first converted to its UTF-8 byte form, and then each byte is encoded separately.

The letter é is two bytes in UTF-8, with hexadecimal values C3 and A9. So café encodes to caf%C3%A9: the three ASCII letters pass through untouched and the accented letter becomes two percent sequences. This is why encoded text grows so quickly. Each unsafe ASCII character becomes three characters, and a non-ASCII character becomes six or more. The growth is expected, not a fault. It also means counting % sequences counts bytes, and bytes and characters are only the same thing in plain ASCII.

How to percent-encode text, step by step

  1. Open the URL Encoder/Decoder.
  2. Choose Component mode for a query value, or Full URL mode for a whole address.
  3. Paste your text or URL.
  4. Press Encode or Decode.
  5. Copy the result.

The mode choice matters. Component mode encodes everything a URL cannot carry raw, including &, =, ? and /, which is what a single value needs. Full URL mode encodes spaces and stray characters while keeping the address structure intact, which is what a whole address needs.

Worked example: three values encoded

All three of these were run through the tool in Component mode.

The phrase hello world & more becomes hello%20world%20%26%20more. The spaces become %20 and the ampersand becomes %26, because in a query string a raw & would start a new parameter.

The value a=b/c becomes a%3Db%2Fc. The equals sign and the slash both have structural jobs elsewhere in a URL, so inside a value they are encoded.

The word café becomes caf%C3%A9, for the UTF-8 reason covered above: one visible character, two bytes, two percent sequences.

In each case decoding the result with the same tool returns the original text exactly.

Limitations and honest warnings

Percent encoding is not encryption, and it hides nothing. Anyone who sees an encoded string can decode it with this same tool, so never put a password or a key in a URL and assume the encoding protects it. URLs get logged and shared in ways passwords should not be.

Encoding also only solves the transport problem. It makes a value safe to carry inside an address; it does not validate the value or fix a badly built URL. And it works byte by byte on the text you give it, so if the text was already mangled before you encoded it, the encoding faithfully preserves the damage.

Common mistakes

  • Leaving an ampersand raw inside a value. A raw & starts a new query parameter and silently splits your data. Encode it as %26.
  • Encoding a whole URL in Component mode. The :, /, ? and = that hold the address together get encoded too. Whole addresses belong in Full URL mode.
  • Assuming an encoded value is secret. Encoding is a public, reversible format. Treat everything in a URL as visible.
  • Hand-typing percent sequences. A stray % or an incomplete %2 makes the string invalid, and the decoder will error rather than guess. Encode with a tool instead.

FAQs

What does %20 mean in a URL? It is a space. Percent encoding writes a byte as a % sign plus its value in hexadecimal, and the space character is byte 20 in hexadecimal, so it appears as %20.

Which characters never need percent encoding? The unreserved characters: letters, digits, and the four marks - _ . ~. They have no structural job in a URL and are always safe to carry raw.

Why does one accented character turn into two percent sequences? Because encoding works on bytes, not characters. The letter é is two bytes in UTF-8, C3 and A9, so it becomes %C3%A9. Each byte gets its own percent sequence.

Is percent encoding a way to hide data in a URL? No. Encoding is not encryption. Anyone can decode a percent-encoded string with the same tool that encoded it, so never treat an encoded value as hidden or protected.

Is + the same as %20 in a URL? In query strings produced by form submissions, + means a space. The Ovatly tool uses %20 instead, which is valid everywhere in a URL and avoids that ambiguity.

Conclusion

Percent encoding is one simple rule, a byte written as % plus two hex digits, applied for one reason: so that characters with structural jobs, and characters with no place in an address at all, can ride inside a URL as data without breaking it. The URL Encoder/Decoder applies that rule in both directions and in both modes. For the practical side, which mode to pick for spaces, symbols and special characters in a real value, see How to Encode Spaces, Symbols and Special Characters in a URL. For more tools like these, see the Developer Tools guide archive.