Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to text. Supports UTF-8. Real-time conversion as you type.
Output will appear here…How Base64 encoding works
Base64 (RFC 4648) takes binary data (or text converted to bytes) and encodes every 3 bytes into 4 printable ASCII characters drawn from a 64-character alphabet: A–Z, a–z, 0–9, +, and /. This makes binary data safe to include anywhere ASCII text is expected — HTTP headers, JSON values, data URIs, and email bodies. The tradeoff is a ~33% size increase.
// JavaScript — browser
btoa("Hello, world!") // → "SGVsbG8sIHdvcmxkIQ=="
atob("SGVsbG8sIHdvcmxkIQ==") // → "Hello, world!"
// Node.js (Buffer)
Buffer.from("Hello").toString("base64") // → "SGVsbG8="
Buffer.from("SGVsbG8=", "base64").toString() // → "Hello"
// Python
import base64
base64.b64encode(b"Hello").decode() # → "SGVsbG8="
base64.b64decode("SGVsbG8=").decode() # → "Hello"
// Command line
echo -n "Hello" | base64 # → SGVsbG8=
echo "SGVsbG8=" | base64 --decode # → HelloCommon use cases for Base64
- Embedding images in HTML/CSS —
<img src="data:image/png;base64,iVBOR...">avoids a separate HTTP request for small icons and favicons. - API authentication headers — HTTP Basic Auth sends credentials as
Authorization: Basic base64(user:pass). - Transmitting binary in JSON — JSON has no native binary type; Base64 is the standard way to include files, images, or binary blobs in JSON payloads.
- Email attachments — MIME encodes all attachments as Base64 before embedding in email bodies.
- JWT tokens — JSON Web Tokens use Base64URL encoding for the header and payload. Use our JWT Decoder to inspect them.
Base64 vs Base64URL
Standard Base64 uses + and /, which are special characters in URLs. Base64URL replaces them with - and _ so the output is safe in query strings and paths without percent-encoding. JWTs use Base64URL for their header and payload segments.
| Variant | Alphabet | Used in |
|---|---|---|
| Base64 | A-Z a-z 0-9 + / | MIME email, data URIs, PEM certificates |
| Base64URL | A-Z a-z 0-9 - _ | JWTs, URL parameters, filenames |
Related Tools
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string using 64 printable characters (A-Z, a-z, 0-9, +, /). It's commonly used to embed images in HTML/CSS, encode email attachments (MIME), and transmit binary data in JSON APIs.
Does this tool support UTF-8 characters?
Yes. This tool fully supports UTF-8 encoding and decoding, including emojis, accented characters, and CJK characters. It correctly handles multi-byte sequences that btoa() alone would fail on.
Why is Base64 output larger than the input?
Base64 encoding increases the size by approximately 33% because it represents 3 bytes of binary data as 4 ASCII characters. For example, a 3 KB file becomes ~4 KB when Base64-encoded. The tool shows the exact size difference.
Is my data safe?
Yes. All encoding and decoding happens entirely in your browser using JavaScript. No data is sent to any server. You can verify this in your browser's Network tab — zero outbound requests.
What is the difference between Base64 and Base64URL?
Standard Base64 uses + and / characters which are special in URLs. Base64URL replaces them with - and _ so the output is safe in query strings, filenames, and URL paths without percent-encoding. JWTs use Base64URL for their header and payload segments.
Can I encode files to Base64?
For file encoding, use the Image to Base64 tool which accepts any image file and outputs a data URI. For general text-to-Base64 conversion, use this tool.
How do I decode Base64 in JavaScript?
Use atob() for simple ASCII strings: atob('SGVsbG8='). For UTF-8 text, use the TextDecoder API: new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0))). In Node.js, use Buffer.from(str, 'base64').toString().
Does this Base64 encoder work offline?
Yes. Once the page is loaded, the tool runs 100% client-side and works without an internet connection.