Encoding encoding binary text

What is Base64 Encoding?

Definition

Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string. It uses 64 characters (A-Z, a-z, 0-9, +, /) to encode every 3 bytes of input into 4 printable characters, making binary data safe for transport over text-based protocols.

Why It Matters

Base64 is essential for embedding images in HTML/CSS (data URIs), transmitting binary attachments in email (MIME), encoding credentials in HTTP Basic Auth headers, and storing binary data in JSON or XML. Nearly every web application uses Base64 somewhere in its stack.

Code Example

import base64
encoded = base64.b64encode(b'Hello, World!')
print(encoded)  # b'SGVsbG8sIFdvcmxkIQ=='

Language: python

Frequently Asked Questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption. It does not provide any security. Anyone can decode a Base64 string without a key. Use AES or RSA for encryption.

Why does Base64 increase data size?

Base64 maps 3 bytes to 4 characters, resulting in roughly a 33% size increase. This trade-off enables safe transport of binary data through text-only channels.

Related Free Tools

Related Terms