Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to plain text — all in your browser, nothing sent to a server.
Frequently Asked Questions
+ and /, which have special meanings in URLs. URL-safe Base64 replaces + with - and / with _, and strips padding = signs. It is used in JWT tokens and OAuth parameters.A–Z, a–z, 0–9, +, /), making it safe to embed in any text format. Common uses include email attachments (MIME), embedding images in CSS/HTML via data URIs, and transmitting binary tokens in HTTP headers.
=) are added to make the output a multiple of 4 characters. The exact formula is: ⌈n / 3⌉ × 4 output characters for n input bytes.
data:[mediatype];base64,[base64data]. For a PNG image in an <img> tag: <img src="data:image/png;base64,iVBORw0KGgo…">. In CSS: background-image: url('data:image/svg+xml;base64,…');. This technique is useful for small icons and inline SVGs but adds payload size and prevents browser caching of the asset separately.
base64 utility: encode with echo -n "hello" | base64, decode with echo "aGVsbG8=" | base64 --decode (use -d on some systems). On Windows PowerShell: [Convert]::FromBase64String("aGVsbG8=") | ForEach-Object { [char]$_ }. With Python: python3 -c "import base64; print(base64.b64decode('aGVsbG8=').decode())". For binary files, pipe the decoded output directly to a file rather than printing to the terminal.
0), uppercase O (O), lowercase l (l), and uppercase I (I) to eliminate confusion when written by hand, while also dropping + and / for URL safety — it adds ~37% overhead.
= characters are appended to make the output length a multiple of 4. One trailing = means the last group had 2 bytes; two == means it had 1 byte. Padding is required by strict decoders but is often stripped in URL-safe Base64 (used in JWTs) since the decoder can infer the correct length. Omitting padding in standard Base64 may cause decoding errors in some libraries.
+ and /, which have special meaning in URLs — + is a space in query strings and / is a path separator. URL-safe Base64 replaces + with - and / with _, and typically omits padding =. It is used in JWT tokens (all three parts are URL-safe Base64 encoded), OAuth 2.0 PKCE code challenges, and anywhere Base64 data appears in URLs, cookies, or HTTP headers where the standard characters would need percent-encoding.
About This Base64 Encoder / Decoder
This free Base64 tool encodes plain text or binary data to Base64 and decodes Base64 strings back to their original form. It supports standard Base64 (RFC 4648) and URL-safe Base64 variants, and all processing happens in your browser.
Base64 is widely used to embed binary data (images, files) in text-based formats such as JSON, XML, HTML data URIs, and email attachments. Decoding Base64 is a common task when inspecting API responses, JWT payloads, and email headers.
When to use this tool
- Encoding images as data URIs for CSS or HTML
- Decoding Base64-encoded API tokens or credentials
- Inspecting JWT header and payload sections
- Embedding binary content in a JSON or XML payload
Standards & References
How Base64 Encoding Works
Base64 converts arbitrary binary data into a stream of printable ASCII characters using a 64-character alphabet.
Group Bytes
The input is read as raw bytes and grouped into chunks of 3 bytes (24 bits). Each group is split into four 6-bit values.
Map to Characters
Each 6-bit value (0–63) maps to a character in the Base64 alphabet: A–Z (0–25), a–z (26–51), 0–9 (52–61), + (62), / (63).
Pad Output
If the input length isn't divisible by 3, padding characters (=) are added to make the output a multiple of 4 characters. URL-safe mode replaces + with - and / with _.
Common Use Cases
HTTP Basic Authentication
The Authorization: Basic header encodes username:password as Base64. Paste the header value here to decode credentials during API debugging (over HTTPS only).
Data URIs
Small images, fonts, and SVGs are embedded directly in HTML/CSS as Base64 data URIs (data:image/png;base64,…), eliminating extra HTTP requests for small assets.
JWT Token Inspection
JSON Web Tokens are Base64URL-encoded. Paste the second segment (payload) to decode it and read the claims — useful for debugging auth flows without a dedicated JWT tool.
Email MIME Attachments
Email attachments in MIME format are Base64-encoded to transport binary files as text. If you've ever seen long strings in raw email source, they're often Base64-encoded file data.
Binary Data in JSON APIs
JSON has no native binary type. Base64 is the standard workaround: images, PDFs, and byte arrays are serialized as Base64 strings before being sent in JSON request or response bodies.
Cryptographic Key Transport
PEM-formatted certificates and private keys are Base64-encoded DER structures wrapped in -----BEGIN…----- headers. Understanding the encoding helps when working with TLS/SSL certificates.
Related Developer Tools
Related Articles
View all articles
Base64 vs Base64url: Why `+`, `/`, and `=` Break URLs, and Why JWTs Use a Different Alphabet
Standard Base64's `+`, `/`, and `=` characters all have special meaning in URLs — which is why a Base64-encoded JWT pasted directly into a URL can silently corrupt, and why Base64url exists as a separate, URL-safe alphabet. Here's exactly which characters differ, why JWTs require Base64url specifically, how padding works and why Base64url commonly omits it, and how to tell the two variants apart.
How Email Attachments Work: MIME Encoding, Base64, and Why Binary Files Need Encoding
Email attachments work because MIME uses Base64 to encode binary files as ASCII text — a system designed in 1992 when email could only carry 7-bit ASCII. Here's how MIME multipart email works, why binary needs encoding, the 33% Base64 overhead on attachment sizes, and how the same system handles HTML form file uploads.
Data URLs and Base64: When to Embed Resources Inline vs Link to Them
Data URLs embed files directly in HTML and CSS as Base64 strings — no separate HTTP request. Here's when that's faster, when it makes things worse, how JWT tokens use Base64URL, and how inline images in emails work around image blocking.
Base64 Encoder/Decoder — What It Is, When to Use It & Why It's Not Encryption
Learn how Base64 encoding works, why it's used in JWTs, Basic Auth, data URIs, and email attachments, why it's not encryption, and how to use a free Base64 encoder/decoder for any data.
Base64 Encoder/Decoder — How It Works & Real Developer Uses
Learn what Base64 encoding is, how it works, why it's used in JWTs, HTTP headers, data URIs, and email attachments — and how to encode or decode any string instantly with a free tool.