What Is URL Encoding (Percent-Encoding)?

Ever seen %20 in a URL and wondered what it means? That's URL encoding — also called percent-encoding — at work.

What it is

URLs can only contain a limited set of characters. Anything outside that set (spaces, accents, symbols like & or ? when they're data) must be percent-encoded: replaced by a % followed by the character's hex byte value.

The classic example: a space becomes %20.

Why it's needed

Some characters have special meaning in a URL:

  • ? starts the query string
  • & separates parameters
  • = assigns a value
  • / separates path segments

If those characters appear inside data (say, a search term), they must be encoded so they aren't mistaken for structure.

Reserved vs unreserved characters

  • Unreserved (A–Z a–z 0–9 - _ . ~) never need encoding.
  • Reserved (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) must be encoded when used as data.
  • Everything else (spaces, non-ASCII) is encoded as its UTF-8 bytes in percent form.

Examples

CharacterEncoded
space%20
&%26
?%3F
é%C3%A9

In code

JavaScript provides encodeURIComponent for encoding data values. The nuances are covered in encodeURIComponent vs encodeURI.

Try it

Paste a URL or text into the URL encoder/decoder to percent-encode or decode it instantly.

Got a config file to check?

Open the config toolkit →