You've seen strings like https://example.com/search?q=hello%20world and wondered what %20 is doing there. That's URL encoding — also called percent encoding — and it's the reason your browser can handle spaces, slashes, and special characters in a URL without everything breaking. This guide explains what it is, when you'll run into it, and how to url encode decode strings quickly.
What Is URL Encoding and Why Do URLs Need It?
A URL is not free-form text. The URL specification defines a strict set of characters that are safe to use directly: letters (A–Z, a–z), digits (0–9), and a handful of symbols (-, _, ., ~). Everything else is either reserved for structural meaning or simply forbidden.
Reserved characters like ?, =, &, and # have specific jobs in a URL. A ? signals the start of a query string. A # starts a fragment. If your data contains these characters — say, a search query that includes an ampersand — using them raw would corrupt the URL's structure.
Non-ASCII characters (accented letters, Chinese characters, emoji) can't appear in a URL at all without encoding. The solution is percent encoding: replace the character with % followed by its two-digit hexadecimal byte value.
A space becomes %20 because space is ASCII byte 32, which is 0x20 in hex. That's it. No magic.
Common Encoded Characters — Quick Cheat Sheet
| Character | Encoded | Where You'll See It |
|---|---|---|
| Space | %20 | Search queries, file paths |
& | %26 | Inside query string values |
= | %3D | Inside query string values |
? | %3F | Nested URLs, query values |
# | %23 | Anchor text in query values |
/ | %2F | File paths inside parameters |
@ | %40 | Email addresses in URLs |
+ | %2B | When + is literal data |
: | %3A | Protocols, ports in query values |
The + vs %20 Distinction
This trips people up constantly. In a URL's path or query value, a space encodes to %20. But in HTML form submissions (using application/x-www-form-urlencoded), browsers encode spaces as + instead.
So when you see q=hello+world in a form submission, the + means space. But if you put a + in a URL to represent a literal plus sign, you must encode it as %2B. Otherwise the receiver will decode it as a space.
The rule: %20 is always a space in any context. + is a space only in form-encoded data. When in doubt, use %20.
When You'll Actually Run Into URL Encoding
Handling file names with spaces. A file named Q4 Report.pdf becomes Q4%20Report.pdf in a URL. Systems that skip encoding often end up with broken download links.
Reading server logs. Logs record the raw encoded URL. Knowing that %2F is a slash and %3A is a colon lets you read logs without losing your mind.
Debugging redirect chains. Encoded characters that get double-encoded (%2520 instead of %20) are a common source of 404s. That %25 is an encoded % — meaning the encoding ran twice.
For HTML content, the encoding works differently. Instead of percent codes, HTML uses named entities like & and <. The SnipKit HTML Entity Encoder handles that conversion if you're working with HTML output.
If you need to encode binary data for transport inside a text field, that's a different problem entirely — Base64 encoding is the right tool for that case.
How to URL Encode Decode Strings in JavaScript
Browsers expose two pairs of functions:
// Encode/decode a complete URL
encodeURI("https://example.com/search?q=hello world")
// → "https://example.com/search?q=hello%20world"
// Encode/decode a single component (a value inside the URL)
encodeURIComponent("AT&T stock price")
// → "AT%26T%20stock%20price"
Use encodeURIComponent for values inside query strings — it encodes reserved characters like & and = that encodeURI intentionally leaves alone.
To decode, flip to decodeURIComponent("AT%26T%20stock%20price") → "AT&T stock price".
For quick one-off encoding and decoding without writing any code, the SnipKit URL Encoder & Decoder handles it in one paste.
FAQ
What is %20 in a URL?
%20 is the percent-encoded form of a space character. URLs cannot contain literal spaces, so any space in a URL path or query string gets replaced with %20. The 20 is the hexadecimal value of ASCII byte 32 — the space character.
What is the difference between + and %20?
Both represent a space, but in different contexts. %20 means space universally — in URL paths, query strings, and anywhere else. + means space only in HTML form data encoded as application/x-www-form-urlencoded. Use %20 if you want a space to work correctly everywhere. A literal + must be encoded as %2B to avoid being misread as a space.
Which characters need to be URL encoded?
Any character that isn't an unreserved character must be encoded. Unreserved characters are: letters (A–Z, a–z), digits (0–9), hyphen (-), underscore (_), period (.), and tilde (~). Everything else — spaces, &, =, ?, #, /, @, non-ASCII characters — needs to be encoded when used as data inside a URL component.
Wrapping Up
Percent encoding is one of those web fundamentals that touches everything — API calls, file downloads, form submissions, server logs. Once you know that %20 is a space and %2F is a slash, a lot of confusing URL behavior suddenly makes sense.
Need to url encode decode a string right now? The SnipKit URL Encoder & Decoder does it instantly in your browser. Paste in a raw string or an encoded URL and get the result in one click.

