Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to text. Supports UTF-8 and Unicode.
What Is Base64 and When Do You Need It?
Base64 is a way of representing binary data using only text characters. It converts raw bytes into a string of letters, numbers, plus signs, and slashes — characters that survive being passed through systems that only handle text (like email, JSON, or HTML).
Think of it like spelling out a phone number in words: "oh-seven-seven-oh" instead of 0770. The information is the same, just represented in a text-safe format. The trade-off? Base64 output is about 33% larger than the original data. That's the cost of text-safety.
Important: Base64 is encoding, not encryption. Anyone can decode it instantly. Never use Base64 to "hide" passwords, tokens, or sensitive data — it provides zero security.
Common Base64 Use Cases
| Use Case | Why Base64? | Example |
|---|---|---|
| Data URIs in HTML/CSS | Embed small images directly in code | <img src="data:image/png;base64,..."> |
| Email attachments (MIME) | SMTP only handles 7-bit ASCII text | Content-Transfer-Encoding: base64 |
| JSON payloads | JSON can't contain raw binary | {"file": "SGVsbG8..."} |
| JWT tokens | Header and payload are Base64URL encoded | eyJhbGciOiJIUzI1NiJ9... |
| HTTP Basic Auth | Credentials encoded (not encrypted!) | Authorization: Basic dXNlcjpwYXNz |
| SVG in CSS | Inline SVG backgrounds without extra requests | background: url("data:image/svg+xml;base64,...") |
What this means for you: If you're embedding small icons (under 2KB) in CSS, Base64 data URIs save HTTP requests. For anything larger, a regular image file with proper caching is more efficient.
Base64 vs Other Encodings
| Encoding | Characters Used | Size Overhead | Best For |
|---|---|---|---|
| Base64 | A-Z, a-z, 0-9, +, / | +33% | Binary data in text contexts |
| Base64URL | A-Z, a-z, 0-9, -, _ | +33% | URLs, JWTs (no +/= characters) |
| Hex | 0-9, a-f | +100% | Hash digests, colour codes |
| URL encoding | %XX format | Variable | Special characters in URLs |
Common Base64 Mistakes
Using Base64 for "security". Base64 is trivially reversible. Encoding a password or API key in Base64 provides zero protection. Use proper encryption (AES) or hashing (bcrypt) for sensitive data.
Base64-encoding large images in CSS. A 50KB image becomes 67KB as Base64, and it can't be cached separately from the stylesheet. Only inline images under 2KB — anything larger should be a regular file with HTTP caching.
Mixing Base64 and Base64URL. Standard Base64 uses + and / which break in URLs. JWTs use Base64URL (with - and _ instead). Decoding one with the other's alphabet produces garbage. Check which variant you need.
Related Tools
How to use this tool
Enter text or Base64 string in the input
Click Encode or Decode
Copy the result or swap input/output
Common uses
- Embedding small images in HTML/CSS as data URIs
- Encoding binary data for JSON payloads
- Decoding JWT token components
- Preparing email attachments for MIME transport
- Converting files for inline SVG backgrounds
Share this tool