URL encoding vs Base64: are they the same thing
No. URL encoding escapes only the characters that are unsafe in a URL context (space becomes %20, Chinese characters become %E4%B8%AD) and leaves safe characters alone; Base64 re-encodes an entire binary blob into plain text, growing it by 33%. The first keeps a URL structurally valid, the second gets binary through a text-only channel.
Key differences
| Aspect | URL encoding (percent-encoding) | Base64 |
|---|---|---|
| Purpose | Make a string safe inside a URL | Make binary safe inside a text channel |
| How it works | Replaces unsafe characters only, rest untouched | Re-encodes everything — all output is new |
| A space becomes | %20 | IA== (as part of the whole-string encoding) |
| Reversible | Fully | Fully |
| Size impact | Only escaped characters grow | Whole payload +33% |
| Obscures content | No — mostly still readable | Yes — unreadable to the eye |
| Typical use | Query parameters, form posts, share links | Data URLs, email attachments, files over APIs |
URL encoding (percent-encoding)
The rule is simple: letters, digits and - _ . ~ stay as they are, every other byte becomes % plus two hex digits. A space becomes %20; the Chinese character 中 is three UTF-8 bytes E4 B8 AD, so it becomes %E4%B8%AD. Note that query strings and path segments follow slightly different rules (in a query, a space may also be written as +), and mixing them produces bizarre decoding results.
Base64
Base64 remaps the whole binary in 6-bit groups onto printable characters. It knows nothing about URL context and does not care whether the input was text or an image. It is the usual choice for Data URLs (data:image/png;base64,…) and for smuggling binary through JSON. Watch out: standard Base64 contains + and /, so you must switch to the URL-safe variant or URL-encode it again before putting it in a link.
How to choose
- Building query strings, handling spaces and non-ASCII → URL encoding
- Carrying images or files through a text protocol → Base64
- Putting a Base64 result into a URL → URL-encode it again, or use the URL-safe variant
Related tools
FAQ
Why is a space sometimes + and sometimes %20
Inside a query string (after the ?), the application/x-www-form-urlencoded rules allow + for a space; inside a path it must be %20. Mixing them breaks decoding.
Can Base64 go straight into a URL
Standard Base64 cannot, because + and / have special meaning in URLs. Either use the - and _ URL-safe variant with padding removed, or wrap it in URL encoding.
Do people combine them
Constantly. The usual chain is file, then Base64, then URL encoding, then into a link. Reverse the order and you get garbage.