📖 What is Base64?
Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of 64 printable ASCII characters. The name "Base64" comes from the fact that 64 characters are used to represent the data.
It is widely used when there is a need to encode binary data that needs to be stored or transferred over media that only support text — such as email attachments, embedding images in HTML/CSS, storing data in JSON, and passing data in URLs.
🔧 Common Use Cases
| Use Case | Example | Why Base64? |
|---|---|---|
| Email Attachments | MIME encoding | Email systems only support 7-bit ASCII text |
| Embed Images in HTML | src="data:image/png;base64,..." |
Avoids separate HTTP requests for small images |
| CSS Background Images | url("data:image/...") |
Inline small icons without extra file requests |
| JSON Data Transfer | Binary data in API responses | JSON only supports text — binary must be encoded |
| HTTP Basic Auth | Authorization: Basic dXNlcjpwYXNz |
Encodes username:password for HTTP headers |
| URL Parameters | Passing binary data in URLs | URL-safe Base64 avoids special character issues |
| JWT Tokens | JSON Web Token payload | Token header and payload are Base64Url encoded |
| Cryptographic Keys | PEM files, certificates | Binary keys stored as readable text strings |
🧮 How Does Base64 Work?
Base64 works by converting every 3 bytes of input into 4 Base64 characters. Here is a step-by-step example of encoding the word "Man":
| Step | Input | Binary | Base64 Output |
|---|---|---|---|
| Characters | M a n |
— | — |
| ASCII Values | 77, 97, 110 | 01001101 01100001 01101110 |
— |
| Split into 6-bit Groups | — | 010011 010110 000101 101110 |
— |
| Decimal Values | — | 19, 22, 5, 46 | — |
| Base64 Characters | — | — | T W F u = TWFu |
✅ So "Man" encodes to "TWFu" in Base64. Base64 always increases the size of data by approximately 33% because 3 bytes become 4 characters.
📖 How to Use the Base64 Encoder & Decoder
Choose Encode or Decode Mode
Click the Encode tab to convert plain text → Base64, or the Decode tab to convert Base64 → plain text.
Set Your Options
Enable URL-Safe mode if your output will be used in a URL. Enable Line Breaks for MIME-compatible output. Leave Live Mode on for instant results as you type.
Paste or Type Your Input
Type or paste your text into the input box. If Live Mode is enabled, the result appears instantly. Otherwise click the Encode / Decode button.
Copy Your Output
Click Copy Output to copy the result to your clipboard. Use the Swap button to flip input and output if you want to re-encode or re-decode.
❓ Frequently Asked Questions
+ and / which have special meanings in URLs. URL-safe Base64 replaces + with - and / with _, making the output safe for use in URLs, filenames, and HTTP headers.
=) are added to ensure the output length is a multiple of 4. One = means 1 padding byte was needed; == means 2 padding bytes.