What is a base64 string?
Base64 writes binary data (for example a key, a file or an image) with 64 printable ASCII characters: A–Z, a–z, 0–9 and two more. Every 3 bytes become 4 characters, so a base64 string is about a third longer than the data it carries; one or two = at the end pad the last block. Base64 is used wherever binary data has to travel through text: e-mail attachments, data URIs, JSON, and the user name and password of HTTP Basic authentication.
Random base64 keys
A random base64 string is a compact way to write a random key. 16 bytes (128 bits) give a 24-character string, 32 bytes (256 bits) a 44-character one – 43 characters in the URL-safe form, which leaves out the padding. Typical uses are session secrets, API tokens for test environments and HMAC keys during development. The bytes come from a cryptographically secure random source. For production secrets, create the key on the machine that uses it, for example with openssl rand -base64 32, so that it never travels over a network.
Decode, encode and related tools
To turn base64 back into text, use the base64 decoder; to convert your own text, the base64 encoder. For percent-encoding in URLs there is the URL encoder and decoder, and the JWT decoder shows the header and the payload of a JSON Web Token.