Base64 vs Base64URL: When to Use Which in Hashes
When you generate a SHA-256 hash, you often need it in text form. That’s where Base64 and Base64URL come in — but they’re not interchangeable.
The Difference in One Table
| Format | Characters | URL-Safe? | Used In |
|---|---|---|---|
| Base64 | + / = | No | Email, JSON, general storage |
| Base64URL | - _ (no padding) | Yes | JWTs, URLs, filenames, APIs |
Why Base64URL Was Created
The characters +, /, and = break URLs and filenames. Base64URL replaces them with safe alternatives and often removes padding — perfect for web tokens.
Example
Same SHA-256 hash of "hello":
- Base64:
aGVsbG8gd29ybGQ= - Base64URL:
aGVsbG8gd29ybGQ
When to Use Which
- Use Base64URL in JWTs, URLs, cookies, filenames
- Use Base64 in JSON, databases, email
- AxelBase gives you both — instantly
FAQ
Can I convert between them?
Yes: replace + → -, / → _, remove =
One wrong character breaks your token. Always use Base64URL when in doubt.