← Imperial Products / Tools / Base64 Encoder & Decoder

Base64 Encoder & Decoder

Encode text to Base64 or decode Base64 back to text instantly. Supports standard and URL-safe variants. Everything runs in your browser — nothing is uploaded.

Input (plain text or Base64)
0 bytes 0 chars
Output
0 bytes 0 chars

What is Base64?

Base64 is an encoding scheme that converts binary data into an ASCII string using 64 printable characters (A–Z, a–z, 0–9, +, /). It is widely used to embed binary content — such as images, certificates, or keys — inside text-based formats like JSON, HTML, CSS, and email.

Standard vs URL-safe Base64

Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 (RFC 4648) replaces them with - and _, making encoded values safe to use directly in URLs and filenames without percent-encoding.

Common Uses

Size Impact

Base64 encoding increases data size by approximately 33%. Every 3 bytes of input become 4 characters of Base64 output.

More Free Developer Tools

How Base64 Encoding Works

Base64 solves a fundamental problem: many protocols and formats were designed to handle ASCII text, but developers need to transmit binary data (images, files, cryptographic keys) through those text-only channels. Base64 does this by taking every 3 bytes of binary data (24 bits) and splitting them into four 6-bit groups, then mapping each group to one of 64 printable ASCII characters: uppercase A–Z (0–25), lowercase a–z (26–51), digits 0–9 (52–61), and two additional characters — + and / in standard Base64, or - and _ in URL-safe Base64. Padding characters (=) are appended when the input length isn't a multiple of 3.

The tradeoff is size: Base64 output is always exactly 4/3 the size of the input, a 33% overhead. For a 100 KB image, the Base64 representation will be about 133 KB. This overhead is acceptable for small assets but becomes significant for large files.

Data URIs: Embedding Files in HTML and CSS

One of the most common developer uses for Base64 is embedding small images, fonts, or SVGs directly in HTML or CSS using a data URI. Instead of referencing an external file with a URL, you encode the file contents as Base64 and embed them inline: src="data:image/png;base64,iVBORw0KGgo...". This eliminates an HTTP request, which can improve performance for small assets like icons. CSS background images, favicon tags, and email HTML templates all commonly use this technique. The downside is that the file can no longer be cached independently by the browser.

API Authentication and JWT

HTTP Basic Authentication encodes credentials as Base64 in the Authorization header: the username and password are concatenated with a colon separator, then Base64-encoded. For example, user:password becomes Authorization: Basic dXNlcjpwYXNzd29yZA==. Note that this is encoding, not encryption — the credentials are trivially recoverable by anyone who can read the header, so Basic Auth must always be used over HTTPS. JSON Web Tokens (JWTs) use URL-safe Base64 (without padding) to encode the header and payload sections, which is why you can decode a JWT's claims using this tool by pasting the middle segment.

Standard vs URL-Safe Base64

Use standard Base64 when encoding binary data for JSON payloads, email MIME parts, or PEM certificate files. Use URL-safe Base64 (the checkbox in this tool) when the encoded value will appear in a URL, query parameter, filename, or HTTP header — the + and / characters in standard Base64 have special meaning in URLs and would need to be percent-encoded, adding even more bloat.