


We use cookies to improve your experience
We use essential cookies to make our site work. With your consent, we may also use non-essential cookies to improve user experience.
Definition
Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is used to embed binary data (images, files) in text-based formats like JSON, HTML, CSS, and email (MIME). Base64 encoded data is about 33% larger than the original.
Base64 encoding converts binary data into a string of printable ASCII characters. Every 3 bytes of binary data become 4 Base64 characters, resulting in a 33% size increase. The encoding uses uppercase letters (A-Z = 0-25), lowercase letters (a-z = 26-51), digits (0-9 = 52-61), and two additional characters (+ and / = 62-63). Padding uses the = character.
Base64 is essential in several common scenarios: embedding small images directly in HTML/CSS (data URIs), sending binary attachments in email (MIME encoding), storing binary data in JSON (which only supports text), and transmitting binary data over protocols that only handle text (like older HTTP implementations or WebSocket text frames).
URL-safe Base64 variants replace + with - and / with _ to avoid URL encoding issues. This variant is used in JWTs, URL parameters, and filenames. While Base64 is not encryption (it is trivially reversible), it is sometimes confused with encryption by beginners. Base64 is encoding, not security — it is designed for data transport, not data protection.