Base64url vs Base64: what’s the difference (JWT-friendly encoding)

Base64url (also written as Base64URL) is a URL-safe variant of Base64. It exists because “normal” Base64 uses characters like + and / that often need escaping in URLs, cookies, and filenames.

Quick summary

Topic Base64 Base64url
Alphabet Uses + and / Uses - and _
Padding Commonly ends with = or == Often omits padding (JWT does)
Where you’ll see it Data URIs, file encoding, email/MIME, generic tooling JWT segments, URL tokens, cookie-safe values

Character mapping

Examples

Base64 vs Base64url strings (same bytes)

Base64:    abcd+efg/hij==
Base64url: abcd-efg_hij

The underlying bytes are the same. The difference is purely the alphabet and padding.

JWTs use Base64url

A JWT is three Base64url-encoded parts separated by dots:

header.payload.signature

Common pitfalls

Try it instantly

Related