RFC 4648
Coding

Base64 Encoder & Decoder

RFC 4648
Wrap:

Raw Plaintext Input

144 characters163 bytes (UTF-8)

Base64 Output

220 characters220 bytes (135% ratio)
RFC 4648 Specification & Architecture Guide

Base64 Encoding, Decoding, and Binary Data Streaming

Base64 represents arbitrary binary octets in an ASCII string format using a radix-64 representation. Standardized by the IETF in RFC 4648, Base64 ensures binary payloads safely traverse transmission channels historically restricted to 7-bit US-ASCII communication, such as SMTP email protocols, MIME envelopes, and JSON payloads.

Base64 Variant Comparison Table

VariantCharacter 62Character 63PaddingPrimary Use Cases
Standard Base64 (RFC 4648 §4)+/=MIME email attachments, HTTP basic auth, data URIs
URL-Safe Base64 (RFC 4648 §5)-_Optional (omitted)JSON Web Tokens (JWT), query parameters, URL path IDs
PEM / OpenSSL Certificate+/=X.509 certificates and RSA keys wrapped at 64 characters
MIME RFC 2045+/=Email bodies wrapped at 76 characters

Bitwise Mechanics: The 24-Bit to 32-Bit Transformation

Base64 segments an incoming sequence of 8-bit octets into groups of 3 bytes (24 bits). These 24 bits are divided into 4 groups of 6 bits each. Because a 6-bit unsigned integer represents values from 0 to 63, each 6-bit chunk maps directly to one character in the Base64 alphabet table:

# Example: Encoding the characters 'M', 'a', 'n'
Input characters: M a n
ASCII octets (8-bit): 01001101 01100001 01101110
Combined 24 bits: 010011010110000101101110
Divided 6-bit groups: 010011 010110 000101 101110
Decimal values: 19 22 5 46
Base64 output chars: T W F u -> "TWFu"

Magic-Byte Signature Sniffing for Decoded Files

When decoding Base64 data without an explicit MIME header, file formats must be inferred from the binary stream itself. PrivaUtils inspects the initial byte markers of the decoded Uint8Array buffer:

PNG Image

89 50 4E 47 0D 0A 1A 0A

Verified via 8-byte PNG header.

JPEG Image

FF D8 FF

Start of image marker (SOI).

WebP Image

52 49 46 46 ... 57 45 42 50

RIFF container with WEBP chunk.

PDF Document

25 50 44 46 2D (%PDF-)

Header identifies Adobe PDF versions.

GIF Animation

47 49 46 38 37 61 (GIF87a/89a)

Standard 6-byte GIF descriptor.

ZIP Archive

50 4B 03 04

Standard local file header signature.

Data URI Schemes in Modern Web Architecture

Base64 encoded files are commonly used in Data Uniform Resource Identifiers (Data URIs), defined under RFC 2397. The syntax embeds multimedia assets directly into HTML documents or CSS stylesheets:

// Standard RFC 2397 Data URI syntax:
data:[<mediatype>][;base64],<data>

// Example inline WebP image:
data:image/webp;base64,UklGRlIAAABXRUJQVlA4TAYAAAAvAAAAAAfQ//73v/+BiOh/AAA=

Frequently Asked Questions

Is Base64 considered encryption?

No. Base64 is an encoding format, not an encryption cipher. Anyone with a Base64 string can decode it immediately without a password or private key. Sensitive information must be encrypted with authenticated ciphers (such as AES-GCM) prior to encoding.

Can I decode malformed Base64 strings?

Base64 requires valid 6-bit character representations and valid 4-character padding blocks. If a string contains illegal characters or missing padding, PrivaUtils reports the conversion issue clearly rather than producing silent data corruption.

Are my files uploaded when converting?

No. All operations run strictly inside your browser memory using Web Workers and typed arrays. No files or strings are dispatched to remote servers.

Related Privacy Utilities

Peer tools running locally in your browser memory without server uploads.

Explore all utilities