The alphabet swap
RFC 4648 defines base64url as the same algorithm with this alphabet and optional padding. JWT (RFC 7515) uses base64url without padding for its header and payload segments.
| Standard | URL-safe | Why |
|---|---|---|
+ | - | + is decoded as a space in query strings |
/ | _ | / is a path separator |
= padding | Often omitted | = is legal but noisy in URLs |
standard: SGVsbG8vV29ybGQ+
url-safe: SGVsbG8vV29ybGQ-
Where it is required
- JWT header, payload and signature segments.
- OAuth PKCE code verifiers and challenges.
- URL query parameters that carry opaque identifiers.
- Filenames derived from content hashes.
- Any context where
+or/has syntactic meaning.
Padding decisions
With padding, the length is always a multiple of four. Without padding, decoders must infer the missing characters. Most modern decoders accept either, but older libraries may require padding. Know which one your consumer expects before choosing.
The two alphabets are not interchangeable at the byte level. Decode with the same variant that encoded the value, or normalize first.