Base64 encoder and decoder

Base64 step by step, 3 bytes into 4 characters of 6 bits, with padding and the URL-safe alphabet.

How it works

Base64 writes any bytes with 64 harmless characters: A to Z, a to z, 0 to 9, + and /. Since $64 = 2^6$, each character carries 6 bits, and 3 bytes (24 bits) become exactly 4 characters. The classic example: Man is 4D 61 6E, that is 010011 010110 000101 101110, the values 19, 22, 5, 46, and so TWFu.

When the length is not a multiple of 3, the last block is filled with zero bits up to a whole number of characters, and = signs fill the block of 4: one byte gives two characters and ==, two bytes give three characters and =. The URL-safe variant (base64url) replaces + and / by - and _ and often drops the padding, so the result can go into a web address or a file name.

Base64 is everywhere binary data must travel as text: e-mail attachments (MIME), data: URLs in web pages, PEM files of keys and certificates, JSON Web Tokens. It is an encoding, not encryption: anyone can decode it.

Everything is calculated in your browser. Nothing you type leaves your device.