Text Input

Base64 OutputLive

Start typing to see live preview...

Base64 Encoder & Decoder - Free Online Tool

Instantly encode text to Base64 or decode Base64 strings online. Free, browser-based, no data sent to servers. Supports UTF-8, Unicode, emojis, and special characters.

What Is Base64 Encoding? A Complete Guide

Base64 is a binary-to-text encoding scheme that converts binary data into a string of 64 printable ASCII characters - uppercase A–Z, lowercase a–z, digits 0–9, plus + and /. The encoding takes every 3 bytes of raw input and maps them to exactly 4 Base64 characters, using = padding when the input length is not a multiple of 3. The result is a text-safe representation that can travel through any system designed to handle plain text without corrupting binary payloads.

The name "Base64" comes directly from the mathematical base of the encoding: 64 possible values per character, compared to binary (base-2) or hexadecimal (base-16). Each Base64 character represents exactly 6 bits of data, so 4 characters = 24 bits = 3 bytes of original binary data. This predictable math is why Base64-encoded data is always roughly 33% larger than the original - a common trade-off developers accept for compatibility across text-only channels.

Originally specified in RFC 2045 as part of the MIME email standard, Base64 has since become a foundational building block of the web. You will encounter it in HTTP Basic Authentication headers (Authorization: Basic dXNlcjpwYXNz), JSON Web Token (JWT) payloads, data URIs for embedding images in HTML and CSS, API payloads, XML/JSON serialization of binary fields, and TLS certificate fingerprints. Understanding Base64 encode and decode is a core skill for any web developer or security engineer.

How to Use This Base64 Encoder / Decoder Tool

This free online Base64 tool processes everything entirely in your browser. Nothing is uploaded to any server - your data stays private on your device.

Encoding Text to Base64

  1. Select the Encode tab at the top.
  2. Enable Live Preview to see the result as you type.
  3. Type or paste any text - plain text, JSON, XML, credentials, HTML, or any Unicode string.
  4. The encoded Base64 string appears instantly in the output panel.
  5. Click Copy to copy the result to your clipboard.

Decoding Base64 to Text

  1. Select the Decode tab.
  2. Paste your Base64-encoded string into the input field.
  3. The decoded plain text is shown instantly in the output panel.
  4. If the Base64 string is malformed, a clear error message is displayed.
  5. Click Copy to copy the decoded output.

Use the Sample button to load an example in the selected mode. The resizable split view lets you adjust panel widths by dragging the divider. Use the fullscreen button to focus on the output. Your last-used input is automatically saved to browser storage for 30 days.

Base64 Encoding Examples

Text → Base64

Input:
Hello, World!
Output:
SGVsbG8sIFdvcmxkIQ==
Input (JSON):
{"user":"alice","role":"admin"}
Output:
eyJ1c2VyIjoiYWxpY2UiLCJyb2xlIjoiYWRtaW4ifQ==

Base64 → Text

Input:
SGVsbG8sIFdvcmxkIQ==
Output:
Hello, World!
Input (HTTP Basic Auth):
dXNlcjpwYXNzd29yZA==
Output:
user:password

Where Is Base64 Used in Real-World Development?

Base64 encoding is ubiquitous in modern software. Here are the most common scenarios where developers need a fast Base64 encoder online tool:

HTTP Basic Authentication

The HTTP Basic Auth scheme requires credentials in the format username:password, Base64-encoded and passed in the Authorization header. For example, user:pass encodes to dXNlcjpwYXNz. This is not encryption - it only enables safe transport over ASCII-only HTTP headers. Always use HTTPS alongside Basic Auth.

JSON Web Tokens (JWT)

The header and payload sections of a JWT are Base64URL-encoded (a variant that uses - and _ instead of + and / for URL safety). Decoding a JWT header or payload manually is a frequent debugging task - you can use this tool to quickly inspect what claims a JWT carries without writing code.

Embedding Images in HTML/CSS (Data URIs)

Small icons and inline images can be embedded directly in HTML or CSS using data URIs: src="data:image/png;base64,iVBORw...". This eliminates an HTTP request for each image and is popular for inlining SVGs, favicons, and small background textures in frameworks and email templates.

Email Attachments (MIME)

Email servers were historically built to carry 7-bit ASCII text. MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode attachments - PDFs, images, and any binary file - so they survive the text-only transport without corruption. RFC 2045 defined this standard, making Base64 a prerequisite for modern email infrastructure.

REST APIs and JSON Payloads

JSON does not natively support binary data. When APIs need to transmit images, audio, or binary files within JSON, Base64 encoding converts the binary to a string field. Base64-encoded file uploads are common in chat APIs, document generation services, and OCR or vision AI APIs that accept images as base64 strings.

Cryptographic Keys and Certificates

PEM (Privacy Enhanced Mail) format - the standard for SSL/TLS certificates, SSH keys, and GPG keys - uses Base64 to encode the underlying DER binary data between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- markers. Inspecting or converting certificates frequently requires Base64 decode operations.

Subresource Integrity (SRI)

When loading scripts or stylesheets from a CDN, browsers verify resource integrity using hashes encoded as Base64 in the integrity attribute: integrity="sha256-abc123...". Generating or verifying SRI hashes requires Base64 encoding of the SHA-256 or SHA-384 digest.

Configuration Files and Environment Variables

Multi-line secrets (private keys, certificates, JSON credentials) are often Base64-encoded to store them as single-line environment variables in CI/CD pipelines, Kubernetes secrets, and Docker configs. Encode with this tool, store the value, and decode at runtime.

Base64 vs Encryption: Critical Security Distinction

Base64 is NOT encryption. This is the single most important thing to understand about Base64. It is an encoding scheme, not a security mechanism. Anyone with a Base64 decoder (including this tool) can instantly read any Base64-encoded data. There is no key, no password, and no cryptographic protection involved.

Base64 (Encoding)

  • Reversible with no key
  • Purpose: text-safe transport
  • Output grows ~33%
  • Not secure for secrets

Hashing (SHA-256)

  • One-way, irreversible
  • Purpose: integrity check
  • Fixed-size output
  • Secure for checksums

Encryption (AES-256)

  • Reversible with secret key
  • Purpose: confidentiality
  • Output is unreadable
  • Secure for sensitive data

Never store passwords, API keys, or sensitive personal data in Base64-encoded form and assume it is protected. Use proper encryption (AES-256-GCM) or hashing with salting (bcrypt, Argon2) for security-sensitive data.

Base64 Encoding Algorithm: How It Works Under the Hood

Understanding the Base64 algorithm helps debug encoding errors and character set issues. Here is a step-by-step breakdown:

  1. UTF-8 conversion: The input text is first converted to its raw byte representation using UTF-8 encoding. For ASCII characters, each character is 1 byte. For Unicode characters (accents, CJK, emojis), each character may be 2–4 bytes.
  2. Group into 3-byte chunks: The byte stream is split into groups of 3 bytes (24 bits each).
  3. Split each 24-bit group into four 6-bit values: Each 6-bit value (0–63) maps to a character in the Base64 alphabet: A=0, B=1, … Z=25, a=26, … z=51, 0=52, … 9=61, +=62, /=63.
  4. Add padding: If the input is not divisible by 3, one or two = characters are appended to make the encoded length a multiple of 4.

Base64URL is a variant used in JWTs and URLs that replaces + with -, / with _, and omits = padding. This makes the output safe for URL query parameters and filenames without percent-encoding.

Character set matters: Always specify UTF-8 when encoding Unicode text. Encoding as a different character set (Latin-1, Windows-1252) will produce a different Base64 string and cause decoding errors if the receiver expects UTF-8. Our tool always uses UTF-8.

Base64 Encode/Decode Code Examples

Use the following code snippets to perform Base64 encoding in popular programming languages:

JavaScript (Browser)

// Encode
const encoded = btoa(unescape(encodeURIComponent("Hello 🌍")));

// Decode  
const decoded = decodeURIComponent(escape(atob(encoded)));

Python

import base64

# Encode
encoded = base64.b64encode("Hello".encode()).decode()

# Decode
decoded = base64.b64decode(encoded).decode()

Node.js

// Encode
const encoded = Buffer.from("Hello").toString("base64");

// Decode
const decoded = Buffer.from(encoded, "base64").toString("utf8");

PHP

// Encode
$encoded = base64_encode("Hello World");

// Decode
$decoded = base64_decode($encoded);

Frequently Asked Questions About Base64

What is Base64 encoding used for?

Base64 is used for encoding binary data (images, files, certificates) into ASCII text so it can be safely transmitted over text-based protocols like HTTP, SMTP (email), and JSON/XML APIs. Common use cases include embedding images in HTML/CSS as data URIs, encoding credentials in HTTP Basic Authentication headers, encoding JWT header and payload sections, transmitting binary files in REST API JSON bodies, and storing PEM-format cryptographic keys and certificates.

Is Base64 encryption? Is it secure?

No. Base64 is encoding, not encryption. Any Base64-encoded string can be decoded by anyone instantly without a key or password. It provides zero confidentiality or security. For secure transmission of sensitive data, use TLS (HTTPS) for transport security, AES-256-GCM for symmetric encryption, and RSA or ECDSA for asymmetric encryption. Base64 is only for format compatibility, not security.

Why does Base64 encoded output end with == or =?

Base64 encodes 3 bytes at a time into 4 characters. When the input length is not divisible by 3, the encoder adds = padding to make the output a multiple of 4 characters. One = means the last group had 2 bytes; two == means the last group had 1 byte. If you see no padding, the input length was a multiple of 3.

Why is the Base64 output larger than the input?

Base64 increases data size by approximately 33% (4/3 ratio). For every 3 bytes of input, Base64 produces 4 characters. Additionally, line breaks in MIME-formatted Base64 (every 76 characters per RFC 2045) add a small overhead. This size increase is the trade-off for making binary data compatible with text-only channels.

Can Base64 encode emojis and non-ASCII characters?

Yes. Our tool correctly handles full UTF-8 encoding, including emojis (🚀, 🎉), accented characters (é, ü, ñ), CJK characters (中文, 日本語), Arabic, Hebrew, and all other Unicode text. The input is first UTF-8 encoded to bytes, and those bytes are then Base64-encoded. Make sure to specify UTF-8 on the decoding side as well.

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / as the 62nd and 63rd characters. These characters have special meaning in URLs (+ means space, / is a path separator). Base64URL replaces + with - and / with _, and omits the = padding. Base64URL is used in JWTs, URL parameters, and filenames. Our encoder outputs standard Base64; for Base64URL, replace the characters after encoding.

Is my data safe when using this online Base64 tool?

Yes. All encoding and decoding happens entirely in your browser using JavaScript's built-in btoa() and atob() functions combined with proper UTF-8 handling. No data is ever sent to any server. You can verify this by opening your browser's Developer Tools and checking the Network tab - you will see zero network requests while using the tool. This makes it safe for encoding credentials, API keys, and other sensitive strings.

How do I decode a Base64-encoded image?

To view a Base64-encoded image, paste the Base64 string (without the data:image/png;base64, prefix) into the Decode tab. The decoded output will be binary data. To render the image in a browser, prefix the full string with data:image/png;base64, (or the appropriate MIME type) and use it as an img src attribute or CSS background-image value.

What are common Base64 decoding errors?

The most common errors are: (1) Invalid characters - Base64 only allows A–Z, a–z, 0–9, +, /, and = padding. Spaces, line breaks, or other characters cause errors unless stripped first. (2) Wrong padding - the encoded string length must be a multiple of 4. (3) Wrong character set - decoding a Base64URL string with a standard decoder fails because of the - and _ characters. (4) Truncated input - partial Base64 strings cannot be decoded.