AXS TXTAXS TXT

URL Encoding (Percent-encoding)

URL encoding (also called percent-encoding) makes text safe to put in a URL by replacing characters that have special meaning — like spaces, &, ? and = — with a % followed by their hex code. A space becomes %20, for example.

This is essential when passing text as a query parameter so the URL isn't broken or misread.

Encode or decode URLs in your browser.

Why it exists

Certain characters have structural jobs inside a URL. A question mark starts the query string, an ampersand separates parameters, a slash separates path segments, and a hash marks the fragment. If your actual data contains one of those, it has to be escaped or the URL is parsed wrongly — usually silently, producing a link that goes somewhere unintended rather than one that visibly fails.

How it works

Percent-encoding replaces a character with a percent sign followed by its byte value in hexadecimal. A space becomes %20, an ampersand %26, a slash %2F. Characters outside ASCII are first encoded as UTF-8 and then each resulting byte is escaped, which is why a single accented letter can expand into two or three escape sequences and why non-Latin text produces such long URLs.

Reserved and unreserved characters

Letters, digits, hyphen, period, underscore and tilde are unreserved and never need escaping. Reserved characters carry structural meaning and must be escaped when used as data rather than as syntax. Everything else should be escaped for safety. The subtlety is that whether a reserved character needs escaping depends on where it appears: a slash is fine inside a path and must be escaped inside a query parameter value.

The plus sign problem

In a query string, a plus sign has historically meant a space, a convention inherited from HTML form submission. In a path segment it means a literal plus. This inconsistency causes real bugs — an email address containing a plus, which many people use for filtering, arrives with the plus turned into a space unless it was encoded as %2B. It is worth encoding plus signs explicitly whenever they are data.

Double encoding

Encoding an already-encoded string escapes the percent signs themselves, so %20 becomes %2520. The result decodes once to %20 rather than to a space, and the value arrives visibly wrong. This usually happens when a value passes through two layers that each helpfully encode it. Encoding exactly once, at the point where a value is placed into a URL, is the rule that avoids it.

Try URL Encode / Decode

Open URL Encode / Decode