Developer Tools · Live
Base64 Encoder / Decoder,
instant, bidirectional, browser-side.
Type plain text to encode it to Base64 in real time or paste a Base64 string to decode it back instantly. Supports full Unicode, URL-safe mode (RFC 4648 §5), and MIME-style line wrapping. Nothing leaves your browser.
Options
Encoding settings
Statistics
Input
16 chars
18 B
Encoded
24 chars
24 B
Ratio
1.333×
+33.3% larger
Variant
Standard
No wrap
Reference
Base64 alphabet (RFC 4648)
A–Z · a–z · 0–9 · + · / · = (padding)
Every 3 bytes of input produce exactly 4 Base64 characters. If the input length is not a multiple of 3, one or two = padding characters are appended to make the output a multiple of 4.
Developer guide
What Base64 is, how it works, and when to use it.
Base64 is one of the most widely used encoding schemes in software engineering, yet it is also one of the most misunderstood. It is often mistaken for encryption, when in reality it is a purely reversible transformation that serves a single purpose: making arbitrary binary data safe to transmit over text-only channels.
The problem Base64 solves
Early internet protocols (SMTP for email, HTTP/1.x, XML, JSON) were designed around the ASCII character set. A raw binary stream (an image, a TLS certificate, a compiled binary) contains arbitrary byte values, including bytes that are interpreted as control characters, null terminators, or that break text encodings in transit. When a protocol strips or mangles these bytes, the data becomes corrupted. Base64 converts every byte into safe, printable ASCII characters, guaranteeing that the data arrives intact.
How the algorithm works
Base64 takes the input byte stream, groups it into 3-byte (24-bit) chunks, and converts each chunk into four 6-bit values. Each 6-bit value (0–63) maps to one of 64 printable ASCII characters:
If the input length is not divisible by 3, the last group is zero-padded to 24 bits, and one or two = characters are appended to signal the padding. The result is always a multiple of 4 characters, and the encoding ratio is always exactly 4/3: roughly 33% larger than the original.
Worked example
Encoding the three-character string "Man":
a = 0x61 = 01100001
n = 0x6E = 01101110
Combined: 010011 010110 000101 101110
= 19 · 22 · 5 · 46
= T W F u
URL-safe Base64 (RFC 4648 §5)
Standard Base64 uses + and /, which have special meanings in URLs. URL-safe Base64 (also called Base64url) replaces them:
+→-(hyphen)/→_(underscore)- Padding
=is usually omitted (since it would be percent-encoded as%3Din URLs)
Use URL-safe Base64 for: JWT tokens, OAuth tokens, PKCE code verifiers, URL parameters, cookies, and filenames. JSON Web Tokens specifically require URL-safe Base64 without padding (called “Base64url” in RFC 7515).
Base64 in common technologies
- JWT (JSON Web Tokens). All three segments (header, payload, signature) are Base64url-encoded, separated by dots:
xxxxx.yyyyy.zzzzz. The header and payload are JSON objects encoded in URL-safe Base64 without padding. - HTTP Basic Authentication. Credentials are formatted as
username:password, Base64-encoded, and sent in theAuthorizationheader:Authorization: Basic dXNlcjpwYXNz. This is not encryption; it provides no security without HTTPS. - PEM certificates. TLS/SSL certificates, private keys, and CSRs are stored as Base64-encoded DER data between
-----BEGIN CERTIFICATE-----and-----END CERTIFICATE-----markers, wrapped at 64 characters per line. - Data URIs. Images and other binary assets can be inlined in HTML/CSS without a separate file request:
<img src="data:image/png;base64,iVBOR..."> - Email attachments. MIME encodes binary attachments as Base64 within the email body, wrapped at 76 characters per line.
Privacy: client-side only
This tool performs all encoding and decoding entirely inside your browser using the native btoa() / atob() functions and the TextEncoder / TextDecoder APIs. No data is sent to any server. The contents of your textareas never leave your machine.
Unicode and multi-byte characters
The native btoa() function in browsers only accepts Latin-1 characters. This tool pre-encodes your text as UTF-8 bytes using TextEncoder before calling btoa(), so any Unicode input (emoji, Arabic, Chinese characters, mathematical symbols) is correctly handled. When decoding, TextDecoder interprets the bytes as UTF-8, recovering the original characters exactly.