Base64 Encode Online

Convert any text or string into Base64-encoded format.

Need to decode? Go to Base64 Decode

What Is Base64 Encoding?

Base64 encoding is a method of converting binary data into an ASCII string format. It uses a set of 64 characters — the uppercase letters A-Z, lowercase letters a-z, digits 0-9, plus (+), and slash (/) — to represent binary data in a text-safe format. The name "Base64" comes directly from this 64-character alphabet.

Base64 was originally designed to allow binary data to be transmitted over channels that only reliably support text content, such as email (MIME), XML documents, and JSON payloads. Today, it is used extensively in web development, APIs, data storage, and many other applications.

Key fact: Base64 encoding increases the size of the data by approximately 33%. A 3-byte input produces 4 Base64 characters. This trade-off is generally acceptable because the encoded data becomes safe to transmit through any text-based protocol.

How Does Base64 Encoding Work?

  1. Convert to bytes — The input text is first converted into its binary byte representation using UTF-8.
  2. Group into 6-bit chunks — The binary data is divided into groups of 6 bits each (since 2^6 = 64).
  3. Map to Base64 characters — Each 6-bit group is mapped to one of the 64 characters in the Base64 alphabet.
  4. Add padding — If the input length is not divisible by 3, padding characters (=) are added to make the output length a multiple of 4.

Common Uses of Base64 Encoding

  • Email attachments (MIME) — Base64 allows binary files like images and documents to be embedded in email messages.
  • Data URIs in HTML/CSS — Small images can be embedded directly using Base64-encoded data URIs, reducing HTTP requests.
  • API authentication — HTTP Basic Authentication encodes the username:password combination in Base64.
  • JSON Web Tokens (JWT) — JWTs use Base64URL encoding to encode the header and payload sections.
  • Storing binary data in text formats — When you need to store binary data in JSON, XML, or database text fields.
  • Cryptographic operations — Encryption keys, certificates, and digital signatures in PEM format.

Important: Base64 is an encoding, not encryption. It does not provide any security. Anyone can decode Base64 back to the original data. Never use Base64 to protect sensitive information.

Frequently Asked Questions

Does Base64 encoding compress data?

No. Base64 actually increases the data size by approximately 33%. If you need to reduce data size, use a compression algorithm like gzip before encoding.

What is the difference between Base64 and Base64URL?

Base64URL modifies the standard Base64 alphabet to be URL-safe by replacing + with - and / with _, and by removing the trailing = padding. This variant is commonly used in JWTs and URL parameters.