Base64 vs Base64URL

Base64URL is Base64 with two alphabet characters swapped (+ -> -, / -> _) and padding usually dropped, so the result can be used directly inside a URL, filename, or cookie without percent-encoding.

Updated: 2026-08-11

Loading

The exact alphabet difference

Standard Base64 uses A–Z, a–z, 0–9, +, / as its 64 symbols.

Base64URL replaces + with - and / with _, because + and / have special meaning in URLs (space and path-segment separator, respectively) and would otherwise need percent-encoding.

Padding

Standard Base64 pads its output with = to a multiple of 4 characters.

Base64URL commonly omits padding entirely — the input length plus the alphabet is enough to decode unambiguously in most implementations — though some specs still require it, so check the consuming system.

Where Base64URL is required

JWTs: the header, payload, and signature segments are all Base64URL-encoded specifically so the token can be passed in a URL, HTTP header, or cookie without escaping.

Passing standard Base64 output where Base64URL is expected (or vice versa) is a common source of 'invalid token' errors when the underlying bytes happen to produce a + or /.

Engineering Notes

i
Most language standard libraries expose both encoders separately (e.g. base64.urlsafe_b64encode in Python) — reach for the URL-safe variant explicitly rather than post-processing standard Base64 output with string replace.

Related Concepts

Base64

Related Tools

Related Reference