Base64 Image Encoder

by feedthebot

Tool converts an image to base64 data.
Acceptable file extensions: image/jpeg, image/png, image/gif, image/bmp, image/webp, image/svg+xml.
Encoding
Show code
opens a modal with image preview, usage examples, image width & height, ...
Copy image
copies this base64 code to your clipboard: data:image/jpeg;base64,/9j/4AA...
Copy css
copies this base64 code to your clipboard: url('data:image/jpeg;base64,/dfs/fdA...
filename width / height size converted

What is Base64 Encoding?

Base64 encoding is a method for converting binary data, such as images or files, into a text string. This encoding makes the data easier to transfer over text-based protocols like HTTP, email, and XML. By converting the data into a string of ASCII characters, Base64 ensures that it can be safely transmitted and stored without data corruption.

How Does Base64 Encoding Work?

Base64 encoding works by dividing the binary data into 6-bit chunks. Each chunk is then mapped to a specific ASCII character based on a predefined Base64 index table. Here’s a step-by-step breakdown:

  1. Divide the Data: The binary data is divided into groups of three bytes (24 bits);
  2. Convert to 6-Bit Groups: Each 24-bit group is further divided into four 6-bit groups;
  3. Map to Base64 Characters: Each 6-bit group is then mapped to a corresponding ASCII character using the Base64 index table;
  4. Padding: If the binary data isn’t a multiple of three bytes, padding characters (=) are added to make the final output a multiple of four characters.

What is Base64 Used For?

Base64 encoding serves multiple purposes in various applications, including:

  • Embedding Images in HTML/CSS: Developers use Base64 to embed image data directly within HTML or CSS files, reducing the number of HTTP requests needed to load a webpage;
  • Email Attachments: It encodes email attachments to ensure their correct transmission over text-based email protocols;
  • Data URI Scheme: Base64 embeds small files, such as images and fonts, directly into HTML, CSS, or JavaScript using the Data URI scheme;
  • Authentication: It encodes credentials in the Basic Authentication scheme for HTTP requests;
  • Storing Binary Data: Base64 stores binary data safely in text-based formats like JSON and XML.

How to Convert Image to Base64 Format?

To convert an image to Base64 format, use our ‘Base64 Image Encoder.’ Choose an image in one of the following formats: JPEG, PNG, GIF, BMP, WebP, or SVG+XML.

base64 image encoder

Press the ‘Go’ button, wait a few seconds, and receive the result for img elements and CSS background elements.

base64 encoder result