You have seen it: a URL with %20 where a space should be, or a query string full of %2F and %3D. That is URL encoding, also called percent-encoding, and it is how URLs safely carry characters that would otherwise break them. Understanding it helps you build links that work, debug broken ones, and avoid the subtle bugs that come from unencoded parameters. This guide explains what it is and when to use it.
Why URL encoding exists
URLs are only allowed to contain a limited set of characters, letters, digits, and a few symbols. But real data often contains spaces, ampersands, slashes, and non-English characters that either are not allowed or have special meaning in a URL. A raw space would break the link; a raw & in a value would be mistaken for a parameter separator. URL encoding solves this by replacing unsafe characters with a percent sign followed by their hexadecimal code, so the data travels intact.
What %20 and friends mean
Each encoded character is a % followed by two hex digits representing the character’s byte value. So a space becomes %20, a slash becomes %2F, an equals sign becomes %3D, and an ampersand becomes %26. When your browser or server reads the URL, it decodes these back into the original characters. That is why you sometimes see %20 in an address bar, it is simply an encoded space that has not been displayed in its friendly form.
Which characters get encoded
Characters fall into three groups:
| Group | Examples | Encoded? |
|---|---|---|
| Unreserved (safe) | A-Z a-z 0-9 – _ . ~ | Never |
| Reserved (special meaning) | / ? : @ & = + # | Encoded when used as data, not as syntax |
| Unsafe / other | space, quotes, non-Latin characters | Always encoded |
The tricky group is the reserved characters: a / is fine as a path separator, but if it appears inside a value it must be encoded to %2F so it is not mistaken for structure.
Encode the whole URL or just a component?
This is the distinction that causes most bugs. There are two levels of encoding:
- Component encoding (encodeURIComponent) escapes everything that is not unreserved, including
/,?,&and=. Use it when encoding a single value you are inserting into a URL, like a search term going into a query parameter. - Full-URL encoding (encodeURI) leaves the URL’s structural characters intact and only escapes truly unsafe ones. Use it when encoding a complete URL you do not want to break.
The classic mistake is using the wrong one: full-URL encoding a value leaves its & and = unescaped, so a value like a=b&c=d silently becomes extra parameters and corrupts your query string.
URL encoding and SEO
For SEO, the practical advice is to keep URLs clean in the first place: use readable slugs with hyphens rather than spaces and special characters, so encoding is rarely needed in your page paths. Encoding mostly comes up in query parameters, tracking links, search URLs, filters, where it is essential for correctness but should be kept out of the pages you want indexed. And remember that %20 in a public-facing URL looks messy; a hyphenated slug is both cleaner and more shareable.
The double-encoding trap
One bug deserves a special warning: double-encoding. If you encode a value that is already encoded, the percent signs themselves get encoded, so %20 becomes %2520 (because % becomes %25). The link then breaks, or the receiving system reads a literal %20 instead of a space. This usually happens when a value passes through two systems that each “helpfully” encode it. The fix is to encode exactly once, at the point where you insert raw data into a URL, and to decode once when reading it back. If you see %25 sequences where you expected normal encoding, double-encoding is almost always the cause, and decoding once will reveal the already-encoded string underneath.
Encode and decode URLs instantly
When you need to encode a value or decode a mysterious percent-string, do not do the hex by hand. Our free URL encoder and decoder converts text to encoded form and back in your browser, with a component-mode toggle so you can pick the right level. To see how a full URL breaks down into its parts and parameters, the URL parser decodes and lays out every component.
The takeaway
URL encoding replaces unsafe and reserved characters with percent-codes (a space becomes %20) so URLs carry data without breaking. The key decision is component versus full-URL encoding, use component encoding for individual values and full-URL encoding for whole links, and keep your indexable page URLs clean so encoding stays in the query string. Encode or decode anything with the URL encoder/decoder, and explore the rest of our free SEO tools.