GS
genstack.tools
RFC 4648 Encoding Specification

Base64 Encoder & Decoder

Encode and decode strings, images, and binary assets to Base64 and CSS Data URIs. 100% in-browser client execution with full UTF-8 Unicode support.

25 characters
bash
encoded.b64.txt
SGVsbG8sIEdlblN0YWNrIFdvcmxkISDwn5qA
FILE: encoded.b64.txt·LINES: 1·SIZE: 36 B
UTF-8 READY
IETF RFC 4648 Technical Standard

Base64 Architecture, Radix-64 Encoding & Data URI Performance

Base64 is a binary-to-text encoding scheme designed to transmit arbitrary octet sequences across legacy communication channels that strictly guarantee ASCII text integrity. Understanding its mathematical radix, UTF-8 boundaries, and network overhead is critical for systems architects.

The 6-Bit Radix Mapping

Standard bytes are 8 bits. Base64 divides incoming bitstreams into 6-bit chunks ($2^6 = 64$ possible values). Each 6-bit chunk indexes into a 64-character alphabet: A-Z (0–25), a-z (26–51), 0-9 (52–61), + (62), and / (63).

The 33% Size Expansion Law

Because 3 raw bytes (24 bits) require 4 Base64 characters (24 bits) to represent, encoding increases payload volume by exactly 33.3% ($\lceil 4n/3 \rceil$). If the input byte count is not divisible by 3, trailing padding characters (=) are appended to preserve frame alignment.

URL-Safe Variant (RFC 4648 §5)

In HTTP URIs and filenames, standard Base64 characters + and / cause URL parsing collisions. The URL-safe dialect replaces + with hyphen (-) and / with underscore (_), omitting trailing padding.

Client-Side UTF-8 Multibyte Hazards in Web Browsers

The native browser JavaScript function window.btoa() expects binary strings where each character code occupies at most 1 byte (Latin-1 range 0x00 to 0xFF). Attempting to pass multi-byte UTF-8 characters (Turkish letters like ş, ğ, ı, Arabic scripts, CJK glyphs, or emojis) triggers a fatal DOMException: The string that to be encoded contains characters outside of the Latin1 range.

// High-performance UTF-8 encoding without Latin-1 exception

const bytes = new TextEncoder().encode(unicodeString);

const binString = Array.from(bytes, (b) => String.fromCharCode(b)).join("");

const base64 = btoa(binString);

GenStack Tools utilizes the native TextEncoder and TextDecoder APIs, ensuring full fidelity for international languages and emojis with zero character corruption.

Contextual Tool Cluster · Cloud, DevOps & Developer Suite

Continue Your Engineering Workflow

Explore All 37 Specifications