Free Online Base64 Encoder & Decoder
Turn text into Base64, or decode a Base64 string back into text. It handles UTF-8 characters and has a URL-safe option. Your text stays in your browser. To convert an image, use the Image to Base64 tool.
How Base64 Encoding Works (RFC 4648)
Base64 is a group of binary-to-text encoding schemes formalized under RFC 4648. It is engineered to serialize arbitrary binary payloads (raw bytes, images, executable binaries, and cryptographic signatures) into a sequence of printable ASCII characters. Early communication protocols—including SMTP (email), HTTP header transport, and JSON interchange—were strictly designed to handle printable 7-bit ASCII text and would mangle control codes or non-printable binary bytes (values 0x00 to 0x1F and 0x7F to 0xFF). Base64 guarantees safe, uncorrupted transmission across all text-oriented channels.
The Radix-64 Bit Conversion Mechanism
Base64 operates on an alignment called a 24-bit quantum. Exactly 3 bytes of binary input (3 × 8 bits = 24 bits) are divided into 4 segments of 6 bits each. Since 26 = 64, each 6-bit chunk maps directly to one of 64 defined ASCII characters:
Bits 1-8
Bits 9-16
Bits 17-24
4 Output Characters
Standard Base64 vs. URL-Safe Base64 (RFC 4648 §4 vs §5)
When encoding data for different network layers, selecting the proper character alphabet is essential to prevent data parsing corruption:
| Specification | 62nd Char | 63rd Char | Padding Char | Typical Application |
|---|---|---|---|---|
| Standard Base64 (RFC 4648 §4) | + (plus) |
/ (slash) |
= (equals) |
MIME email attachments, HTTP Basic Auth, Data URIs. |
| URL-Safe Base64 (RFC 4648 §5) | - (minus) |
_ (underscore) |
Omitted or = |
JSON Web Tokens (JWT), query parameters, URL routing. |
Understanding the 33% Data Expansion Overhead
Because Base64 translates every 3 bytes (24 bits) of raw data into 4 characters (32 bits), the encoded output is mathematically 4 / 3 = 1.3333... times the size of the original input. This represents an unavoidable 33.33% storage and bandwidth expansion. For this reason, high-throughput systems avoid using Base64 for large media files where native binary streaming (such as HTTP multipart/form-data or binary WebSockets) is available.
Multibyte UTF-8 Unicode Support in Modern JavaScript
A classic developer trap in JavaScript is using the legacy window.btoa() function directly on UTF-8 strings. The browser's native btoa() only supports the Latin-1 character range (bytes 0 to 255); passing emojis or multilingual scripts (such as Arabic, Chinese, or Urdu) causes the browser to throw a fatal InvalidCharacterError DOMException.
AioGalaxy WebTools resolves this issue by passing Unicode text through a complete TextEncoder / TextDecoder byte array pipeline, ensuring 100% fidelity across all global language character sets.
Base64 Implementation Examples in Backend Code
Encoding and decoding operations across modern languages:
Python 3
import base64
# Standard Base64
encoded = base64.b64encode(b"Hello World").decode("utf-8")
decoded = base64.b64decode(encoded).decode("utf-8")
# URL-Safe Base64
url_safe = base64.urlsafe_b64encode(b"Hello World").decode("utf-8")Node.js
// Standard Base64
const encoded = Buffer.from('Hello World', 'utf-8').toString('base64');
const decoded = Buffer.from(encoded, 'base64').toString('utf-8');
// URL-Safe Base64
const urlSafe = Buffer.from('Hello World').toString('base64url');PHP 8
// Standard Base64
$encoded = base64_encode('Hello World');
$decoded = base64_decode($encoded);
// URL-Safe Base64
$urlSafe = rtrim(strtr(base64_encode('Hello World'), '+/', '-_'), '=');Frequently Asked Questions
What is Base64 encoding and why is it essential for internet protocols?
Base64 is a binary-to-text encoding scheme defined in RFC 4648 that represents arbitrary binary data using an alphabet of 64 printable ASCII characters. It is essential for transmitting binary payloads (such as images, attachments, or cryptographic keys) across text-oriented network channels (like MIME emails, JSON payloads, or HTTP headers) that would otherwise corrupt raw non-printable bytes.
Does Base64 provide encryption or security for confidential data?
No. Base64 is purely a data representation format, NOT an encryption algorithm. It uses no secret key and offers zero cryptographic confidentiality. Anyone can decode a Base64 string instantly using standard tools. Never use Base64 alone to protect passwords, personal data, or private credentials.
Why does Base64 encoding increase data size by approximately 33%?
Base64 represents 6 bits of data using one 8-bit ASCII character. Therefore, every 3 bytes (24 bits) of raw binary data requires 4 ASCII characters (32 bits) to encode. This introduces an inherent mathematical overhead of 33.33% (ratio of 4/3), plus up to two '=' padding characters.
What is URL-Safe Base64 (RFC 4648 Section 5) and when is it required?
Standard Base64 incorporates '+' and '/' characters, which have reserved functional meanings in URI parameters and query strings (e.g., '+' represents a space, and '/' separates directory paths). URL-Safe Base64 substitutes '+' with '-' and '/' with '_', and frequently omits trailing '=' padding to allow safe embedding in URLs, file systems, and JSON Web Tokens (JWTs).
How does Base64 padding with '=' characters work?
Base64 processes input in 24-bit chunks (3 bytes). If the total byte count is not divisible by 3, padding characters ('=') are appended at the end to ensure the output length is a multiple of 4: one '=' indicates a 2-byte remainder, while '==' indicates a 1-byte remainder.
How are multibyte UTF-8 Unicode strings (emojis, accents) handled in Base64?
Legacy browser functions like window.btoa() only support 8-bit Latin-1 characters and crash when encountering multibyte UTF-8 symbols (such as emojis or Arabic/Urdu script). AioGalaxy WebTools uses a modern UTF-8 encoder pipeline to properly serialize multibyte code points into valid byte sequences before encoding.
Can binary files (images, audio, PDFs) be converted using Base64?
Yes. Binary files can be encoded into Data URIs (e.g. data:image/png;base64,...) for direct inline embedding into HTML, CSS, or JSON documents. For image files specifically, AioGalaxy provides a dedicated 'Image to Base64' tool in the Image Tools category with file drag-and-drop support.
Is my data transmitted to a remote server when encoding or decoding on AioGalaxy?
No. All encoding and decoding operations execute 100% locally within your client browser using JavaScript. No text, tokens, or payloads are transmitted across the network, ensuring zero latency and total client-side privacy.