What Is Base64 Encoding?
Learn what Base64 encoding is, how it works, and why it is used for transmitting binary data over text-based systems.
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters. It converts any binary data — images, files, or raw bytes — into a string of printable characters that can be safely transmitted over text-based protocols like email, HTML, JSON, and XML.
Why Base64 Exists
Many internet protocols were designed to handle only text data. When you need to embed an image in an HTML email or include a file in a JSON API response, binary data cannot be transmitted directly. Base64 encoding solves this by converting binary data into a text string that preserves the information while being compatible with text-only systems.
How Base64 Encoding Works
Base64 works by taking every 3 bytes of binary data and converting them into 4 Base64 characters. Each character is selected from a table of 64 characters: A-Z (26), a-z (26), 0-9 (10), and + and / (2). The = character is used as padding when the input length is not divisible by 3. This means Base64-encoded data is approximately 33% larger than the original binary data.
Common Use Cases
Base64 is used for embedding images directly in HTML and CSS (data URIs), encoding credentials in HTTP Basic Authentication, transmitting binary data in JSON and XML, storing binary data in databases that only support text, email attachments (MIME encoding), and embedding fonts in CSS.
Try Tool Elixir Base64 Tool
Tool Elixir provides a free Base64 encoder and decoder that works entirely in your browser. Paste your text to encode or your Base64 string to decode. The tool handles UTF-8 text correctly and shows both the encoded and decoded results in real time.