Base64 Converter
Encode text to Base64 and decode Base64 to text
Base64 Encoded
Enter input above
About Base64
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It is commonly used when there is a need to encode binary data that needs to be stored and transferred over media designed to deal with text. Common uses include email attachments, data URLs, and API tokens.
What Is Base64 Encoding?
Base64 encoding is a binary-to-text encoding scheme that represents binary data as a string of 64 printable ASCII characters. The Base64 alphabet consists of uppercase letters A-Z (values 0-25), lowercase letters a-z (values 26-51), digits 0-9 (values 52-61), and the plus sign (+, value 62) and forward slash (/, value 63). The equals sign (=) is used as padding when the encoded output is not a multiple of 4 characters.
Base64 is the most widely used binary-to-text encoding on the internet. It was originally defined in RFC 4648 and is employed wherever binary data needs to be stored or transmitted over media designed for text. The encoding expands the original data by approximately 33%, meaning every 3 bytes of binary input produce 4 characters of Base64 output.
The primary use cases for Base64 include email attachments (MIME encoding), data URLs in web pages, API authentication tokens, embedding images in HTML or CSS, and encoding JWT (JSON Web Token) payloads. Understanding Base64 is essential for web developers, API integrators, and anyone working with data serialization.
How Base64 Encoding Works
Base64 encoding converts binary data to text by grouping input bits into 6-bit chunks and mapping each chunk to a character in the Base64 alphabet. Because 6 bits can represent 64 different values (2⁶ = 64), the encoding uses exactly 64 characters.
Base64 Encoding Process
Where:
- Input= Original binary data in 8-bit bytes
- 6-bit groups= Input bits regrouped into sets of 6
- Output= Base64 string with = padding to multiple of 4
Common Uses of Base64
Base64 encoding appears throughout modern computing and the internet. Understanding where and why it is used helps developers work effectively with APIs, web technologies, and data serialization.
| Use Case | How Base64 Is Used |
|---|---|
| Email Attachments | MIME encoding converts binary attachments to Base64 for transport over SMTP |
| Data URLs | Embed images directly in HTML/CSS using data:image/png;base64,... |
| API Tokens | JWT tokens encode header and payload as Base64 |
| HTTP Basic Auth | Username:password pair is Base64-encoded in the Authorization header |
How to Use This Calculator
The Base64 converter supports both encoding and decoding operations:
- Select the mode: Click "Encode" to convert text to Base64, or "Decode" to convert Base64 back to text.
- Enter the input: Type or paste your text (for encoding) or Base64 string (for decoding) into the text area.
- View the result: The converted output appears below, with a "Copy" button for convenience.
- Check the statistics: For valid conversions, the input and output character counts are displayed, showing the expansion factor.
The converter handles UTF-8 text correctly, supporting international characters and emojis.
Real-World Applications
Base64 is ubiquitous in web development and APIs. When you authenticate to an API using HTTP Basic Auth, your username and password are Base64-encoded in the Authorization header. JWT (JSON Web Token) uses Base64URL encoding for its header and payload components. Understanding Base64 is essential for debugging API requests and constructing proper authentication headers.
In email systems, MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode binary attachments. When you attach a PDF or image to an email, the mail client Base64-encodes it so it can travel over text-only email protocols. The encoded data appears as a block of seemingly random characters in the email source.
Front-end web development frequently uses data URLs, which embed Base64-encoded images directly in HTML or CSS files. This eliminates additional HTTP requests for small images like icons and logos, though it increases the overall document size by about 33%.
Worked Examples
Encoding Text to Base64
Problem:
Encode the string 'Hello, World!' to Base64.
Solution Steps:
- 1Convert each character to ASCII: H=72, e=101, l=108, l=108, o=111, ,=44, (space)=32, W=87, o=111, r=114, l=108, d=100, !=33
- 2Convert ASCII values to 8-bit binary: 01001000 01100101 01101100 ...
- 3Group into 6-bit chunks and map to Base64 alphabet
- 4Result: SGVsbG8sIFdvcmxkIQ==
Result:
'Hello, World!' encoded = SGVsbG8sIFdvcmxkIQ==
Decoding Base64 to Text
Problem:
Decode the Base64 string 'SGVsbG8sIFdvcmxkIQ==' back to text.
Solution Steps:
- 1Remove the padding characters (=): SGVsbG8sIFdvcmxkIQ
- 2Map each Base64 character to its 6-bit value
- 3Regroup into 8-bit bytes
- 4Convert bytes to ASCII characters: H, e, l, l, o, ,, (space), W, o, r, l, d, !
Result:
SGVsbG8sIFdvcmxkIQ== decoded = 'Hello, World!'
Base64 Expansion Ratio
Problem:
How large will the Base64 encoding of a 300-byte binary file be?
Solution Steps:
- 1Base64 encodes every 3 bytes into 4 characters (expansion ratio of 4/3 ≈ 1.333)
- 2Calculate encoded length: 300 × 4/3 = 400 characters
- 3Check if padding is needed: 300 is divisible by 3, so no padding needed
- 4Verify: 400 characters is exactly 300 × 4/3
Result:
A 300-byte file produces exactly 400 Base64 characters
Tips & Best Practices
- ✓Base64 expands data by about 33% — a 3-byte input always produces 4 characters of output
- ✓Trailing = signs indicate padding; they can be removed before decoding in most implementations
- ✓Base64 is not encryption — it provides zero security and is trivially reversible
- ✓Base64URL replaces +/ with -_ and removes padding for use in URLs and file names
- ✓JWT tokens use Base64URL encoding for their header and payload components
- ✓HTTP Basic Auth base64-encodes 'username:password' — never use it without HTTPS
Frequently Asked Questions
Sources & References
Last updated: 2026-06-06
Help us improve!
How would you rate the Base64 Converter?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: NIST Guide to SI Units
by National Institute of Standards