Encodings

Base64url

RFC 4648 base64 with - and _ for URLs and file names. Unpadded the way JWT writes it
IDbase64url13 / 20base64 · 64 characters
Encoding / Base64

Base64url

Base64 that survives a URL.

Overhead
+33% on random bytes
Padding
none
Standard
RFC 4648 §5
Used by
JWT
family 2 / 20

Sample

Out
aGVsbG8gd29ybGQh
Back
"hello world!"

Access

Importimport { base64url } from "@agntn/encodings/base64"
CLIencodings encode base64url 'hello world!'
Tryplayground with the sample above
Kinbase64

Base64 with - and _ instead of + and /. It survives a URL and a file name. No padding, because that's what JWTs write.

ts
encode("base64url", '{"alg":"HS256","typ":"JWT"}');
// "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"

Look familiar? Every JWT starts with eyJ, because every JWT starts with {". Decoding takes the padding when it's there. Text without - or _ is valid base64 and base64url at once, which is why identify calls those a tie.