Base64 vs Base64URL: What's the Difference?
Base64URL is a URL-safe variant of Base64 encoding. While they work similarly, Base64URL uses different characters to avoid issues in URLs and filenames.
Key Differences
| Feature | Base64 | Base64URL |
|---|---|---|
| Character 62 | + (plus) | - (hyphen) |
| Character 63 | / (slash) | _ (underscore) |
| Padding | Required (=) | Optional/omitted |
| URL Safe | No (needs escaping) | Yes |
| Filename Safe | No (/ is invalid) | Yes |
| RFC | RFC 4648 §4 | RFC 4648 §5 |
Why the Different Characters?
The + Problem
In URLs, the + character has special meaning—it represents a space. When Base64 data containing + is placed in a URL, it gets misinterpreted:
The / Problem
The / character is a path separator in URLs and invalid in filenames. Including it in Base64 data breaks URL routing and file systems.
The = Problem
The = padding character is used for query parameter assignment in URLs. Base64URL typically omits padding entirely to avoid confusion.
Example Comparison
Encoding the same data with both methods:
>>>???Pj4+Pz8/(contains + and /)Pj4-Pz8_(uses - and _)When to Use Each
Use Base64URL for:
- • JWT tokens
- • URL query parameters
- • Filenames
- • Cookies
- • OAuth tokens
- • Any URL-embedded data
Use Standard Base64 for:
- • Email attachments (MIME)
- • Data URIs in HTML/CSS
- • PEM certificates
- • XML/JSON payloads
- • Database storage
- • When compatibility is critical
Converting Between Formats
Converting between Base64 and Base64URL is straightforward—just swap the characters:
JWT and Base64URL
JSON Web Tokens (JWTs) use Base64URL encoding for their header and payload sections. This ensures the token can be safely passed in URLs, headers, and cookies without encoding issues.
Try Both Formats
Our encoder/decoder supports both Base64 and Base64URL. Try them side by side to see the differences.
Open Encoder/Decoder →