Home / 🃏 Internet/ Base64 Encode/Decode

Base64 Encode / Decode

Print
Encode text, files, and images into Base64 format or decode Base64 data back into standard formats instantly and securely client-side.
Base64 Text Encoder / Decoder
Result
Base64 Image or File Encoder
Base64 Data URI

Transmitting raw binary files across networks or saving binary assets inside text-based storage engines can cause data corruption. Many communication channels and database protocols are designed exclusively to process readable text characters. Base64 translation bridges this gap.

Our free online Base64 Encode / Decode tool allows you to convert text, images, and binary files in two modes:

  • Text Converter: Instantly encode or decode plain text strings using standard character encodings like UTF-8.
  • Image or File Converter: Upload images or binary files to convert them to Base64 strings, or input a Base64 string to export and download the original file.

*Security Guarantee: All encoding and decoding actions run locally inside your browser using client-side JavaScript. Your data and files are never uploaded to the internet or sent to external servers.


What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that translates raw binary data into a sequence of readable ASCII characters. It is commonly used in modern web protocols, API payloads, and email transmission systems.

The standard Base64 character set (defined by RFC 4648) uses 64 printable characters:

  • Uppercase letters (A-Z) representing values 0 to 25.
  • Lowercase letters (a-z) representing values 26 to 51.
  • Numerical digits (0-9) representing values 52 to 61.
  • The plus sign (+) for value 62 and the slash (/) for value 63.

The equals sign (=) is reserved exclusively as a padding character at the end of an encoded string to ensure the output matches expected bit alignments.

Data Size Overhead

Computers naturally process data using bytes, where 1 byte equals 8 bits. Base64, however, maps data using 6-bit chunks. Because 6 bits represent one Base64 character, the encoding process takes groups of 3 bytes (24 bits) and splits them into 4 separate 6-bit blocks (24 bits).

This conversion results in a data expansion of exactly 4/3 (roughly 1.33 times) the size of the original file, meaning a Base64-encoded file is about 33% larger than its binary source.


Base64 Encoding Examples and Bit Division

The following examples illustrate how the algorithm processes character inputs, manages binary arrays, and applies padding characters.

Example 1: Encoding the word “Dog” (No Padding Required)

The word “Dog” contains exactly 3 characters, totaling 24 bits (3 × 8 bits), which divides evenly into four 6-bit Base64 blocks:

Parameter Step-by-Step Values
Input Letter D o g
8-Bit Decimal (ASCII) 68 111 103
Binary Representation (24 Bits) 01000100 01101111 01100111
6-Bit Division 010001 000110 111101 100111
6-Bit Decimal Value 17 6 61 39
Base64 Output Character R G 9 n

Thus, the word Dog translates to RG9n.

Example 2: Encoding the word “Do” (Requires One “=” Padding Character)

If the input data contains 2 characters, it totals 16 bits. We divide these into 6-bit blocks, leaving 4 bits remaining in the final block. We append 2 zero bits to complete the last 6-bit block, and add one = character to pad the remaining space:

Parameter Step-by-Step Values
Input Letter D o [Padding]
8-Bit Decimal (ASCII) 68 111
Binary Representation (16 Bits) 01000100 01101111
6-Bit Division + Zero Padding 010001 000110 111100 [Pad]
6-Bit Decimal Value 17 6 60
Base64 Output Character R G 8 =

Thus, the word Do translates to RG8=.

Example 3: Encoding the word “Dogs” (Requires Two “=” Padding Characters)

If the input data contains 4 characters, it totals 32 bits. We divide these into 6-bit blocks, leaving 2 bits remaining in the final block. We append 4 zero bits to complete the last 6-bit block, and add two = characters to pad the remaining space:

Parameter Step-by-Step Values
Input Letter D o g s [Padding]
8-Bit Decimal (ASCII) 68 111 103 115
Binary Representation (32 Bits) 01000100 01101111 01100111 01110011
6-Bit Division + Zero Padding 010001 000110 111101 100111 011100 [Pad] [Pad]
6-Bit Decimal Value 17 6 61 39 28 48
Base64 Output Character R G 9 n c w ==

Thus, the word Dogs translates to RG9ncw==.


Common Uses of Base64 Encoding

Base64 encoding is widely implemented in web technologies and data storage:

  • Email Attachments (MIME/SMTP): The standard Simple Mail Transfer Protocol (SMTP) was historically built to handle only 7-bit ASCII text characters. Base64 encoding allows binary attachments (like PDFs, ZIP files, and images) to be converted into ASCII text, enabling legacy mail servers to route them without corruption.
  • Embedding Binary Data in HTML/CSS: You can use the Data URI scheme to embed small images, icons, or PDF files directly within your HTML code or CSS style sheets, reducing the number of external HTTP requests. For example, the following snippet embeds a PNG image directly:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAA" />

To convert binary IP masks, visit our IP Subnet Calculator. To compute base-16 equations, use our Hex Calculator. For base-2 data translations, use the Binary Calculator.


Frequently Asked Questions (FAQ)

Is Base64 a form of encryption?

No. Base64 is strictly an encoding format designed for data serialization and transmission compatibility. It does not hide information or provide security, as anyone can decode a Base64 string instantly using standard public algorithms.

Why are equal signs (=) used at the end of Base64 strings?

The equals sign (=) is a padding indicator. Because Base64 maps 3-byte binary segments into 4-character blocks, any remainder of 1 or 2 bytes is padded with trailing zero bits, which are represented by = or == placeholders at the end of the text string.

How does encoding affect file size?

Because Base64 converts 3 bytes of data into 4 characters, it increases the total file size by approximately 33% (a 4:3 ratio). For large media files, this overhead can increase page load times and hosting bandwidth usage.

Can I encode files locally offline?

Yes. Our Base64 converter runs entirely client-side using your browser’s processor. No data is transmitted across the internet, making it safe to encode private documents or keys offline.