What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters (AโZ, aโz, 0โ9, +, and /), with = used for padding. The name comes from the 64 characters used in the alphabet. Each Base64 character encodes exactly 6 bits of binary data, meaning every 3 bytes of input become 4 Base64 characters โ increasing the data size by approximately 33%. Base64 was standardized in RFC 4648 and is universally supported across programming languages, browsers, and operating systems.
Base64 is not a form of encryption โ it is purely an encoding mechanism designed to safely transport binary data over channels that were designed to handle text. A URL-safe variant replaces + with - and / with _, making the encoded string safe to embed in URLs and file names without percent-encoding. Data URIs (data:<mime>;base64,<data>) are a common application, allowing images and other binary assets to be embedded directly inside HTML, CSS, or JSON without a separate HTTP request.
Common Use Cases
- Email attachments โ MIME email protocols use Base64 to encode binary files (images, PDFs) so they can travel through text-based email systems without corruption.
- Embedding images in HTML/CSS โ Small icons and background images can be inlined as Base64 data URIs to eliminate extra HTTP requests and simplify asset bundling.
- API and JSON payloads โ Binary data (audio, images, certificates) is Base64-encoded before being included in JSON fields or HTTP request/response bodies.
- JWT tokens โ JSON Web Tokens use URL-safe Base64 to encode their header and payload sections for compact, URL-friendly transmission.
- Configuration and secrets โ Kubernetes secrets, environment variables, and configuration files often store binary credentials or keys as Base64 strings for safe storage in text-based formats.
Related Tools
Format and validate JSON โ JSON Formatter
Generate secure passwords โ Password Generator
Count words and characters โ Word Counter
