What Is Percent-Encoding?

Why a URL is full of things like %20 and %C3%A9, explained from first principles. This page is an explainer, not a tool.

← Back to the URL Encoder

This page is concept-only and has no encoder. To actually encode or decode text, use the URL Encoder tool; to see how it is done in JavaScript, read the JavaScript encoding page.

Percent-encoding writes a byte that a URL cannot carry directly as a percent sign plus two hex digits. A space becomes %20, and the accented letter é becomes %C3%A9. It is also commonly called URL encoding; its formal name in RFC 3986 is Percent-Encoding.

① Why does percent-encoding exist?

A URL (URI) was designed for plain ASCII, and a set of its characters were given structural meaning. That creates three problems:

  1. The character set is too small: a URL can only safely carry a limited set of ASCII characters. Accented letters, emoji and every other non-ASCII character are not in it, so they need another spelling.
  2. Some characters are the skeleton, not content: : / ? # & = @ are there to separate the scheme, the path, the query string and the fragment. If the content itself contains a ? and it is not encoded, the browser reads it as "the query string starts here" and the URL structure falls apart.
  3. Some characters are not allowed at all: spaces, < > " { } and control characters are illegal in a URL.

Percent-encoding is the single answer to all three: any character that is unsafe, or that you want to use as content, is written as %XX.

② The rules: really just three steps

Most people assume one character maps to one %XX. There is a UTF-8 byte layer in between.

Step 1 · Take one character — say é.
Step 2 · Encode it to UTF-8 bytes first. é is 2 bytes in UTF-8: C3 A9.
Step 3 · Write each byte as % + two hex digits: C3→%C3, A9→%A9, which gives %C3%A9.
CharUTF-8 bytes (hex)Percent-encoded
éC3 A9 (2 bytes)%C3%A9
€E2 82 AC (3 bytes)%E2%82%AC
space20 (1 byte)%20
A41 (1 byte)A (no encoding needed)
&26 (1 byte)%26

Key idea: percent-encoding encodes bytes, not characters. That is why é becomes two %XX groups and € becomes three, while an ASCII letter stays exactly as it is.

Diagram showing the character é encoded to UTF-8 bytes C3 A9 and then to percent-encoded bytes %C3%A9.
1/3 · Characters become UTF-8 bytes first; each byte is written as % plus two hexadecimal digits.

③ Characters fall into three classes

RFC 3986 splits ASCII into three classes, and that is what decides whether a character can stay as-is in a URL.

ClassWhich charactersEncode?Notes
Unreserved
always safe
A-Z a-z 0-9 - _ . ~ Never encoded Safe everywhere — they can appear exactly as they are.
Reserved
structural
:/?#[]@ !$&'()*+,;= Depends They carry structural meaning. Used as structure they stay as-is; used as ordinary content they must be encoded.
Other / unsafe space, " < > \ ^ ` { } |, control characters, and everything non-ASCII (accented letters, emoji) Always encoded Illegal in a URL — always %XX.

The single most important sentence: the same character is treated differently depending on where it sits. A ? that opens the query string is skeleton and stays; but if a parameter value genuinely needs to contain a question mark it must be written %3F, or it will be mistaken for the start of the query string.

④ Each part of a URL: what may stay as-is

This is where people most often get stuck — the rules are not uniform across the whole URL, they are per segment.

PartExampleCharacters that may stay as-is
schemehttps:letters, digits, + - .
hostexample.comletters, digits, - . ~ % and some sub-delims
path/café/menuunreserved + :@ and / (as a separator) + sub-delims
query?q=café&page=2unreserved + /?&= (as structure) + sub-delims
fragment#section-3same as query, plus # itself

So the correct approach is to encode part by part: encode the scheme, the host, each path segment, each parameter name and each parameter value separately, then join them with the structural characters — instead of throwing the whole URL at an encoder in one go (that encodes :// ? & too, and the URL breaks).

Diagram separating a URL into its scheme, host, path, query, and fragment so only the data is encoded.
2/3 · A URL has structure. Keep its separators in place and encode the data within each part.

⑤ A full walkthrough with a real example

Turning https://example.com/café?q=café & tea into a legal URL.

original: https://example.com/café?q=café & tea

# split into parts, encode each one, keep the structural characters:
scheme      https:                 → unchanged
host        example.com            → unchanged
path        /café                  → /caf%C3%A9
param name  q                      → unchanged
param value café & tea             → caf%C3%A9%20%26%20tea

result: https://example.com/caf%C3%A9?q=caf%C3%A9%20%26%20tea

Note that : // ? = all stay as they are; only the accented letters, the spaces and the ampersand in the content were encoded.

Diagram showing scheme, host, path segment, query parameter name, and query parameter value as separate URL components.
3/3 · Encode each path segment and query name or value separately, then join them with URL separators.

⑥ Four common misunderstandings

Why should dynamic URL values be percent-encoded?

Dynamic text can contain characters that have structural meaning in a URL. If an ampersand from a search term is left raw inside a query value, a server may interpret the text after it as another parameter; spaces and non-ASCII text also need a representation the URI can carry. Encode the inserted value as its own component, then assemble it with the URL's real separators. Keep the original text until the receiving application has parsed the right component and decoded it. Percent-encoding is data formatting, not encryption or access control.

What are the reasons behind URL encoding?

Use percent-encoding to represent bytes that cannot safely appear raw in a URI component, and to keep data characters from being mistaken for delimiters such as &, =, ?, or #. It also gives non-ASCII text a defined byte representation. The goal is to preserve the value while the URL is parsed—not to encode every character in the complete link. Leave the scheme, host, and intended path/query separators in place, and encode only the data component that needs it.

⑦ Where to go next

→ URL Encoder tool (actually encode / decode) → URL encoding in JavaScript, with code examples

This page is an explainer with no requests and no uploads · a static page, ready to read.

Watch: What Is Percent-Encoding?

See UTF-8 bytes turn into percent escapes, and learn why URL separators must stay intact.

Watch on YouTube

Related tools

Every tool on this site runs entirely in your browser. Pick the encoding problem you have: