🔗developer

URL Encoding Explained: What %20 and %2F Actually Mean

Percent encoding shows up constantly in web development and nobody explains why it exists. Here's the complete picture: what URLs can contain, what needs encoding, and how to encode/decode correctly.

6 min readOctober 28, 2025Updated January 18, 2026By FreeToolKit TeamFree to read

Frequently Asked Questions

Why does a space become %20 in URLs?+
URLs are defined by RFC 3986, which specifies that only certain characters are allowed: letters (A-Z, a-z), digits (0-9), and a small set of special characters (-._~:/?#[]@!$&'()*+,;=). A space is not in that allowed set. Percent encoding (also called URL encoding) represents any disallowed character as % followed by its hexadecimal ASCII code. The ASCII code for space is 32, which is 20 in hexadecimal, so space becomes %20. The % symbol itself is represented as %25. This encoding makes URLs transmittable as ASCII strings over HTTP, regardless of what characters the original data contains.
What's the difference between encodeURI and encodeURIComponent in JavaScript?+
encodeURI() encodes a complete URL, preserving characters that have meaning in URL structure: : / ? # [ ] @ ! $ & ' ( ) * + , ; =. These characters aren't encoded because they're structural parts of the URL. encodeURIComponent() encodes everything except letters, digits, and -_.~. This includes the structural characters like / and ?. Use encodeURIComponent() for query parameter values and path segments that might contain those structural characters. Use encodeURI() when you have a complete URL and want to encode spaces and non-ASCII characters without breaking the URL structure.
Are + and %20 both valid for spaces in URLs?+
Both appear in practice, but they're technically different. %20 is the proper percent encoding for space (ASCII 32) per RFC 3986 and RFC 3986. The plus sign (+) represents a space only in application/x-www-form-urlencoded format (the format used in HTML form submissions via GET). In URL path segments, + is a literal plus sign. In query strings, + may be decoded as space by some servers (following HTML form encoding conventions) but RFC 3986 says it should be a literal plus. %20 is always unambiguous. + is form-encoding context-specific. When in doubt, use %20.

🔧 Free Tools Used in This Guide

FT

FreeToolKit Team

FreeToolKit Team

We build free browser tools so you don't have to install anything.

Tags:

urlencodingweb-developmenthttp