B64

Base64 Encoder & Decoder

Encode text to Base64, decode Base64 to text, or convert files and images — instantly in your browser.

Text Input
Base64 Output
Advertisement Space

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of printable ASCII characters. It uses a set of 64 characters — uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), and two additional symbols (+ and /). The name "Base64" comes directly from this 64-character alphabet. Every three bytes of binary input produce four characters of Base64 output, making encoded data roughly 33% larger than the original.

Why Use Base64?

Many protocols and systems were originally designed to handle text, not raw binary data. Email (SMTP/MIME), JSON, XML, and HTML all work best with printable characters. Base64 encoding lets you embed binary content — images, documents, cryptographic keys — safely within these text-based formats without corruption. It is the standard method for encoding attachments in email, embedding images in CSS and HTML via data URIs, and transmitting binary payloads in REST APIs.

Common Use Cases

  • Data URIs: Embed small images directly in HTML or CSS using data:image/png;base64,... to reduce HTTP requests and improve page load performance.
  • API payloads: Transmit files, tokens, and binary data inside JSON request and response bodies without worrying about encoding issues.
  • Email attachments: MIME encoding uses Base64 to safely embed files within email messages across different mail servers and clients.
  • Authentication: HTTP Basic Authentication encodes the username:password pair in Base64 before sending it in request headers.
  • Cryptography: Public keys, certificates (PEM format), JWTs, and digital signatures are commonly represented as Base64-encoded strings.

Data URIs Explained

A data URI (Uniform Resource Identifier) allows you to include data inline in web pages as if they were external resources. The format is data:[mediatype][;base64],data. For example, a small PNG image can be embedded directly in an <img> tag's src attribute. This eliminates a network round-trip, which is especially beneficial for icons, logos, and other small assets. However, Base64 encoding increases file size by about a third, so data URIs are best suited for files under a few kilobytes.

URL-Safe Base64

Standard Base64 uses + and / characters which have special meaning in URLs. URL-safe Base64 (also called Base64url, defined in RFC 4648) replaces these with - and _ respectively, and typically omits padding. This variant is used in JWTs (JSON Web Tokens), URL parameters, and filenames where standard Base64 characters would cause parsing issues.

How This Tool Works

This Base64 encoder and decoder runs entirely in your browser. No data is sent to any server — all encoding and decoding happens client-side using the browser's native btoa() and atob() functions with full UTF-8 support. You can encode text to Base64, decode Base64 back to text, convert files and images to Base64 strings via drag-and-drop, toggle URL-safe mode, and copy results to your clipboard instantly. The live conversion updates as you type with no page reloads needed.