What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It uses a set of 64 characters (A-Z, a-z, 0-9, +, /) to encode data, with = used for padding. Base64 encoding is commonly used when binary data needs to be transmitted over media designed for text.
Common Use Cases
Base64 encoding is widely used in email attachments (MIME), embedding images in HTML/CSS (data URIs), storing complex data in JSON or XML, encoding authentication credentials (HTTP Basic Auth), and transmitting binary data through APIs. It is not encryption — Base64 is easily reversible and should not be used for security purposes.
How It Works
Base64 works by taking groups of 3 bytes (24 bits) and splitting them into 4 groups of 6 bits. Each 6-bit group maps to one of 64 characters. If the input length is not divisible by 3, padding characters (=) are added. This process increases the data size by approximately 33%.