URL Encoding, Explained: What %20 Actually Is
The "%" codes in URLs are not corruption — they are a precise language. Here is how percent-encoding works and when it matters.
Daniel Osei
Software Engineer & Developer Tools
Every space in a web address shows up as %20, and if you have ever wondered why, you are looking at percent-encoding — the standard way URLs carry characters they are not allowed to contain.
Why URLs cannot just have spaces
URLs use special characters structurally: ? starts the query, & separates parameters, # starts a fragment, / separates paths. If a value could contain any of those, the URL would be ambiguous. Percent-encoding solves this by reserving a safe alphabet and encoding everything else.
How %20 works
A percent sign followed by two hex digits represents one byte. Space is byte 0x20, hence %20. The "&" is 0x26, so a query value containing & becomes %26. The pattern is mechanical: take the UTF-8 bytes, write each as %XX.
"Hello world & friends" encodes to "Hello%20world%20%26%20friends"Two encoding rules, one common bug
encodeURIComponent() encodes almost everything, making values safe inside a query string. encodeURI() leaves structure characters intact, keeping whole URLs readable. The classic bug: encoding an entire URL with the component rule turns its :// and & into garbage, breaking the link.
When it matters to you
- Links with spaces or symbols break when not encoded.
- Query values with user input must be encoded or they can corrupt the request.
- Emoji and accents need UTF-8 encoding to survive URLs.
- Some characters (like /) are structural in some positions and data in others — encoding depends on position.
In doubt, encode every query value and only query values. Leave the URL structure alone. The URL Encoder/Decoder shows both modes side by side.
Is %20 the same as a plus sign in URLs?
In query strings, "+" means space in the older form encoding. In paths, only %20 is correct. Modern frameworks use %20 everywhere.
Do I need to encode my own links?
Browsers auto-encode many characters in the address bar, but encoded output is what you want to store, share and embed — it is unambiguous and predictable.
Written by Daniel Osei
Daniel builds developer tools and writes about JavaScript, JSON and everything that lives in the terminal.
Tools used in this article
Encode and decode URLs, query strings and components.
JSON Formatter
PopularPretty-print, validate and minify JSON — securely in your browser.
Turn any title into a clean, URL-ready slug.
Related articles
JSON Formatter: A Beginner's Tutorial (With Real Examples)
JSON is everywhere, but minified JSON is unreadable. Learn to format, validate and understand JSON in under ten minutes.
JSON Formatter vs Minifier: When to Use Each
Both transform JSON — one for humans, one for machines. Here is when each matters and why the difference is not cosmetic.
