Base64 Encoder and Decoder

Base64 is a binary-to-text encoding scheme that represents arbitrary byte data as a string of 64 printable ASCII characters. It is used wherever binary content needs to travel through a text-only channel: email attachments are Base64-encoded inside MIME messages, images are embedded in HTML and CSS files as Base64 data URIs, binary file contents are stored in JSON and XML documents, and HTTP Basic Authentication sends credentials as a Base64 string in the request header. The algorithm groups input bytes in sets of three, converts each group of 24 bits into four 6-bit values, and maps each 6-bit value to a character from the set A-Z, a-z, 0-9, + and /. If the input length is not divisible by three, one or two padding characters (=) are appended. This tool lets you encode any plain text to Base64, or paste a Base64 string to decode it back to plain text. Everything runs in your browser using JavaScript's built-in btoa() and atob() functions; nothing you enter is sent to a server. The encoder handles standard ASCII text; the decoder works on any valid Base64 string. Enter your text below to encode it, or switch to the decode tab to convert Base64 back to plain text.

Calculate.co.nz is proud to be partnered with Health Based Building, a leader in sustainable and health-conscious building innovation. With over a century of experience, they develop high-performance systems like Foreverbreathe Specification, Magnum Board, and Foreverbreathe Paints to support energy-efficient, non-toxic living environments. Their commitment to healthier homes aligns with our belief that informed choices lead to better outcomes for Kiwi households.
Calculate.co.nz partner: Health Based Building
Advertise on this page
SGVsbG8gV29ybGQ=
Base64 encoded output
Input length11 chars
Output length16 chars
Size ratio1.45x

Base64 encoded text is approximately 33% larger than the original. Nothing is uploaded; all processing runs in your browser.

How it works

Encoding uses the browser's built-in btoa() function, which converts a string of Latin-1 characters to Base64. Decoding uses atob(), which reverses the process. If the input contains characters outside the Latin-1 range (such as accented or Unicode characters), the encoder first converts the text to a UTF-8 percent-encoded string and then encodes that. Invalid Base64 input in decode mode shows an error message. The size ratio is output length divided by input length, showing the overhead Base64 introduces.

Worked example

Input "Hello World" (11 characters). H encodes to 72 in ASCII, e to 101, and so on. The 11 bytes are grouped in sets of 3, converted to Base64 characters, and padded to a multiple of 4. The result is "SGVsbG8gV29ybGQ=" (16 characters), a size ratio of about 1.45x. Decoding "SGVsbG8gV29ybGQ=" returns "Hello World". These match the defaults pre-filled above.

Related calculators