Base64 Encode & Decode Tool | Indeetools.com
Convert text to Base64 or decode Base64 back to text instantly Free Online
Encode to Base64
Decode from Base64
What is Base64 Encoding?
Base64 is a method of converting binary information into text format using 64 different printable characters. This encoding technique represents every 6 bits of data with a single character from a predefined set. It's particularly useful for transmitting binary content through systems that are designed to handle only text-based data.
When you encode data using Base64, the resulting output is approximately 33% larger than the original. If you add line breaks for readability (typically every 76 characters), the size increase is closer to 37%. This overhead is the trade-off for ensuring compatibility across text-only communication channels.
Historical Background
The concept of Base64 encoding emerged during the early days of computing when different systems needed to exchange binary data. Early implementations like uuencode for UNIX systems and BinHex for TRS-80 computers (later used on Macintosh) were among the first to use this approach. These early versions made specific assumptions about safe characters based on their target operating systems.
Common Applications of Base64
- Web Development: Embedding images, fonts, and other binary assets directly into HTML, CSS, or JavaScript files using data URIs
- Email Attachments: SMTP email protocol was originally designed for 7-bit ASCII text, so Base64 encoding ensures binary files can be sent reliably
- Data Storage: Storing binary information in JSON, XML, or other text-based formats
- API Communication: Transmitting binary data through REST APIs and web services
- Authentication: Encoding credentials and tokens in HTTP headers
- QR Codes: Representing binary data in a format that's easier to decode accurately
- Cryptographic Keys: Sharing public keys and certificates in a readable text format
- Database Storage: Storing binary data in text columns or legacy database systems
The Base64 Character Set
The standard Base64 alphabet consists of 64 characters used to represent values from 0 to 63:
- Uppercase letters: A-Z (values 0-25)
- Lowercase letters: a-z (values 26-51)
- Digits: 0-9 (values 52-61)
- Special characters: + (value 62) and / (value 63)
- Padding character: = (used to indicate the end of encoded data)
| Value | Char | Value | Char | Value | Char | Value | Char |
|---|---|---|---|---|---|---|---|
| 0 | A | 16 | Q | 32 | g | 48 | w |
| 1 | B | 17 | R | 33 | h | 49 | x |
| 2 | C | 18 | S | 34 | i | 50 | y |
| 3 | D | 19 | T | 35 | j | 51 | z |
| 4 | E | 20 | U | 36 | k | 52 | 0 |
| 5 | F | 21 | V | 37 | l | 53 | 1 |
| ... | ... | ... | ... | ... | ... | 62 | + |
| 63 | / | ||||||
Base64 Variants
Base64URL: A URL-safe variant that replaces '+' with '-' and '/' with '_' to avoid issues with URL encoding. This is commonly used in web applications, JWT tokens, and file names.
MIME Base64: Used in email systems, this variant adds line breaks every 76 characters for better readability and compatibility with email protocols.
How Encoding Works
The encoding process takes every 3 bytes (24 bits) of input data and converts them into 4 Base64 characters (24 bits total, 6 bits per character). When the input length isn't divisible by 3, padding characters (=) are added to complete the final group.
Example: The text "Hello" encodes to "SGVsbG8="
- Input bytes: H(72), e(101), l(108), l(108), o(111)
- Binary groups are converted to Base64 characters
- One padding character is added because 5 bytes aren't divisible by 3