Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to text. Auto-detects direction on paste.
Input
Drop a file here or click to upload
Output
What is Base64 and when do you use it?
Base64 is an encoding that represents binary data (images, files, cryptographic keys) using only printable ASCII characters (A-Z, a-z, 0-9, +, /). It's not encryption — any Base64 can be trivially decoded back to the original bytes. The purpose is transport-safety: getting binary data through channels that only accept text.
Where Base64 shows up daily:
- Data URIs —
data:image/png;base64,iVBORw0KGg...embeds an image directly in HTML/CSS without a separate request. - HTTP Basic Auth —
Authorization: Basic <base64(user:password)>. - JWT tokens — each of the three sections is Base64URL-encoded JSON.
- Email attachments — MIME encodes binary attachments as Base64 so they survive SMTP (which is 7-bit text-only by design).
- PEM certificates / SSH keys — Base64-wrapped DER binary between BEGIN/END headers.
- Browser Blob / FileReader APIs — reading a File as Base64 data URL.
- Config embedding — Kubernetes secrets, GitHub Actions secrets are Base64-encoded for safety in YAML.
Base64 expands output by ~33% (4 output bytes per 3 input bytes, plus padding). Never use it for compression. Never use it as security — anyone can decode.
Base64 vs Base64URL — which are you using?
Standard Base64 uses + and / in its alphabet — which have special meaning in URLs (+ means space, / is a path separator). Base64URL swaps those for - and _, and omits the = padding.
| Base64 (RFC 4648 §4) | Base64URL (RFC 4648 §5) | |
|---|---|---|
| Position 62 | + | - |
| Position 63 | / | _ |
| Padding | = required | = omitted |
| Used by | Email, PEM, HTTP Basic | JWT, OAuth, URLs, filenames |
Our tool detects and handles both. If you paste a JWT section (three dot-separated parts), it's Base64URL — decoder autodetects.
Base64 in Python, JavaScript, Java, Go, C#
# Python (standard library)
import base64
base64.b64encode(b"Hello World").decode() # "SGVsbG8gV29ybGQ="
base64.b64decode("SGVsbG8gV29ybGQ=").decode() # "Hello World"
base64.urlsafe_b64encode(b"Hello World").decode() # Base64URL
// JavaScript (browser + Node)
btoa("Hello World") // "SGVsbG8gV29ybGQ="
atob("SGVsbG8gV29ybGQ=") // "Hello World"
// ⚠ btoa/atob don't handle Unicode directly — use TextEncoder first:
btoa(String.fromCharCode(...new TextEncoder().encode("héllo")))
// Java 8+
Base64.getEncoder().encodeToString("Hello".getBytes());
Base64.getDecoder().decode(encoded);
Base64.getUrlEncoder().withoutPadding().encodeToString(...);
// Go
import "encoding/base64"
base64.StdEncoding.EncodeToString([]byte("Hello"))
base64.RawURLEncoding.EncodeToString(...) // no padding
// C#
System.Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello"));
System.Convert.FromBase64String(encoded);
Converting a PDF / image / any binary file to Base64 happens the same way — read the file as bytes, encode, done. The result is a plain string you can embed in JSON, paste into a config file, or drop into an email body.
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /). It's used to safely transmit binary data in text-based formats.
When should I use Base64?
Common uses include embedding images in HTML/CSS (data URIs), encoding email attachments (MIME), transmitting binary data in JSON APIs, and basic authentication headers.
What is URL-safe Base64?
URL-safe Base64 replaces + with -, / with _, and removes = padding, making the encoded string safe for use in URLs and filenames.
Related Developer Tools
Copyright © 2026 BuildStudio. All rights reserved.
Designed and Developed by Webority Technologies