Base64

Encode & decode strings

About This Calculator

Base64 is an encoding scheme that converts binary data into ASCII text using only 64 printable characters. It is widely used to embed images in HTML/CSS, encode email attachments (MIME), and pass binary data through text-only protocols like HTTP headers and JSON.

Formula

Groups 3 bytes (24 bits) into 4 six-bit values
Each 6-bit value maps to one of 64 characters: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63)
Output is padded with = characters to make length a multiple of 4

Example Calculation

Encode the string 'Hello'

  1. H=72, e=101, l=108, l=108, o=111 in ASCII
  2. Group bytes into 6-bit chunks and map to Base64 alphabet
  3. Result: SGVsbG8=
'Hello' encodes to SGVsbG8= (8 chars, 60% larger than input)

Base64 Alphabet (first 16 values)

ValueCharValueCharValueCharValueChar
0A16Q32g48w
1B17R33h49x
2C18S34i50y
3D19T35j51z
62+63/pad=

Frequently Asked Questions

Does Base64 encrypt data?
No. Base64 is encoding, not encryption. It is easily reversible by anyone — just decode it. It exists to make binary data safe for text-based protocols, not to hide information.
Why does Base64 increase file size?
Base64 uses 4 characters to represent every 3 bytes, which is a 4/3 = 33% size increase. A 1 MB image becomes approximately 1.33 MB when Base64-encoded.
What is URL-safe Base64?
Standard Base64 uses + and / which have special meanings in URLs. URL-safe Base64 replaces + with - and / with _, making it safe to include in URLs and filenames without percent-encoding.
How do I use Base64 to embed an image in CSS?
Convert the image to Base64 and use: background-image: url('data:image/png;base64,ENCODED_DATA'). This embeds the image directly in the CSS, eliminating an HTTP request, which can speed up small icons.