What Is Base64? Encoding Explained
Base64 is a binary-to-text-converter encoding scheme that converts binary data into a string of printable ASCII characters. It was designed to safely transport binary content — such as images, audio files, or cryptographic keys — through systems that only handle plain text, such as email or JSON APIs.
How Does Base64 Work?
Base64 takes every 3 bytes (24 bits) of input and splits them into four 6-bit groups. Each group maps to one of 64 printable characters: A–Z, a–z, 0–9, +, and /. If the input length is not a multiple of 3, padding characters (=) are appended. The output is always about 33% larger than the original.
Common Use Cases
Base64 is used to embed images and fonts directly in HTML or CSS as data URIs, encode binary attachments in JSON or XML API payloads, represent cryptographic keys and certificates in PEM format, and store binary data in databases that only support text columns.
Is Base64 Encryption?
No. Base64 is encoding, not encryption. Anyone can decode Base64 instantly without a key — it just looks like unreadable text. If you need to protect data, use proper encryption such as AES-256. Base64 only changes how data is represented, not whether it is secret.
Base64 vs Base64URL
Standard Base64 uses + and / which are special characters in URLs. Base64URL is a URL-safe variant that replaces + with - and / with _, and omits padding. It is used in JWT tokens, OAuth flows, and any context where the encoded string appears in a URL.