Encodings
Base64url
RFC 4648 base64 with - and _ for URLs and file names. Unpadded the way JWT writes it
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!"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
Access
- Import
import { base64url } from "@agntn/encodings/base64" - CLI
encodings 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.
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.