Base64url

noun

say it: “BAYS SIK-stee-FOR YOO-AR-EL” /beɪs ˈsɪksti fɔr ˌju ɑr ˈɛl/

A way of writing any bytes using only letters, digits, hyphens and underscores, so they're safe in web addresses; anyone can decode it, so it hides nothing.

What is base64url?

Base64url is a way of writing any bytes with only letters, digits, - and _, so they're safe in web addresses and headers. It isn't a lock: anyone can turn it back. A JWT's header and payload are base64url, which is why a token never holds a password.

import base64
import json

part = "eyJzdWIiOiJtYXlhIiwicm9sZSI6Im1lbWJlciJ9"   # a JWT's middle part
padded = part + "=" * (-len(part) % 4)             # put back the = signs JWTs leave off
print(json.loads(base64.urlsafe_b64decode(padded)))   # {'sub': 'maya', 'role': 'member'}

In a sentence

  • “A JWT's payload is only base64url, so Maya decoded hers and read her own user id.”
  • “Base64url uses - and _ instead of + and /, which have meanings in a web address.”

Level: Journeyman · More Web Development terms at this level

Updated