What is Base64 Encoding?
Base64 is a data encoding scheme that converts binary data (like images or compiled code) into a sequence of printable ASCII text characters.
Why do we need Base64?
In the early days of the internet, systems were designed to handle only text data (like emails). When people tried to send binary files (like images or zip archives), the non-text bytes would often get corrupted or misinterpreted by routing systems.
Base64 solves this by translating the binary data into 64 safe, universal characters: A-Z, a-z, 0-9, +, and /.
How does it work?
Base64 works by grouping binary data into 24-bit chunks (3 bytes). It then divides those 24 bits into four 6-bit chunks. Since 6 bits can represent 64 different values (2^6 = 64), each chunk maps directly to one of the 64 safe characters.
Because it takes 3 bytes of raw data and turns it into 4 bytes of text, Base64 encoding always increases the file size by about 33%.
Common Uses
- Email Attachments: MIME (Multipurpose Internet Mail Extensions) uses Base64 to safely transmit files over email protocols.
- Data URLs in CSS/HTML: You can embed small images directly into HTML or CSS files using
data:image/png;base64,...to save an HTTP request. - JSON APIs: Since JSON is text-based, binary payloads must be encoded to Base64 before being sent via an API.
If you need to encode or decode Base64 data, try our free Base64 Encoder / Decoder Tool.