Vaultools
Menu

Base64URL

Base64URL is a variant of Base64 that swaps the characters "+" and "/" for "-" and "_" and usually drops the "=" padding, so encoded bytes can sit safely inside URLs, filenames and JWTs. It is defined in RFC 4648, section 5.

Why a second variant exists

Base64 turns arbitrary bytes into text using 64 characters, and three bytes become four characters. It is an encoding, not encryption: it hides nothing, and anyone can reverse it instantly. Its last two symbols, though, are awkward outside plain text.

What changes in the URL-safe variant

Standard Base64 uses + and / as its last two symbols and = for padding. All three have special meanings in URLs and filenames. Base64URL fixes that:

Standard Base64Base64URL
Symbol 62+-
Symbol 63/_
Padding= (required)= (usually omitted)

The bytes 0xFB 0xFF 0xFE show the difference. Standard Base64 gives +//+ and Base64URL gives -__-.

Padding exists only so the encoded length is a multiple of four. The decoder can work the length out on its own, so JWTs and most URL uses leave it off. Hello is SGVsbG8= with padding and SGVsbG8 without.

Where you will meet it

Common pitfalls

References

Ads on this page

Non-personalized ads help keep Vaultools free — Google decides where they appear on the page.

Go Pro to remove them →