Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to plain text instantly. Supports Unicode, URL-safe encoding, and file-to-data-URI conversion -- all client-side. Your data never leaves your browser.

🔎 This looks like Base64. Click here to switch to Decode mode.

Encode a File to Base64

📎

Drag & drop a file here, or click to browse

Max file size: 5 MB. Output will be a data URI.

How It Works

Instant Conversion

Type or paste text and see the Base64 encoding update in real time. Switch between encode and decode modes with a single click. All processing happens locally in your browser.

🌐

Full Unicode Support

Properly handles multi-byte Unicode characters including emoji, CJK characters, and accented letters using TextEncoder/TextDecoder for accurate encoding and decoding.

🔗

URL-Safe Mode

Encode with URL-safe Base64 (RFC 4648 section 5), which replaces + with -, / with _, and strips padding. Ideal for URLs, filenames, and query parameters.

📄

File to Data URI

Drag and drop or browse to select any file (up to 5 MB). The tool encodes it as a complete data URI, ready to embed in HTML, CSS, or JSON.

Understanding Base64 Encoding

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 ASCII characters. Defined in RFC 4648, Base64 is widely used to embed binary data in text-based formats like HTML, CSS, JSON, XML, and email (MIME). The encoding uses the characters A-Z, a-z, 0-9, +, and /, with = used for padding.

How Base64 Works

Base64 encoding takes every three bytes of input and converts them into four ASCII characters. Each group of 6 bits maps to one of the 64 characters in the Base64 alphabet. If the input length is not a multiple of three, padding characters (=) are appended to the output. This means Base64-encoded data is always about 33% larger than the original binary data.

Common Use Cases

Standard vs. URL-Safe Base64

Standard Base64 uses + and / as the 62nd and 63rd characters, with = for padding. URL-safe Base64 (RFC 4648 section 5) replaces + with - and / with _, and typically omits padding. This variant is used in URLs, filenames, cookies, and JWT tokens where + and / would need percent-encoding.

Frequently Asked Questions

What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses a 64-character alphabet (A-Z, a-z, 0-9, +, /) plus = for padding. Every three bytes of input produce four characters of output, making the encoded result about 33% larger than the original data. Base64 is commonly used when binary data needs to be stored or transferred through systems that only handle text, such as JSON, XML, HTML, CSS, or email.
Is Base64 encoding the same as encryption?
No, Base64 is not encryption. It is an encoding scheme, not a security mechanism. Anyone can decode a Base64 string back to its original form without any key or password. Base64 provides no confidentiality, integrity, or authentication. If you need to protect sensitive data, use proper encryption (such as AES or RSA) before Base64-encoding the result. Base64 is purely a format conversion tool for representing binary data as text.
What is URL-safe Base64?
URL-safe Base64, defined in RFC 4648 section 5, is a variant of standard Base64 that replaces the + character with - (minus) and / with _ (underscore). It also typically omits the = padding characters. This variant is necessary when Base64 data needs to appear in URLs, query parameters, filenames, or cookies, where the standard + and / characters would need to be percent-encoded. URL-safe Base64 is used in JSON Web Tokens (JWTs), Amazon S3 signed URLs, and many other web technologies.
Why is Base64 output about 33% larger than the input?
Base64 works by taking every 3 bytes (24 bits) of input and splitting them into 4 groups of 6 bits. Each 6-bit group maps to one of the 64 characters in the Base64 alphabet. So 3 bytes of input always become 4 bytes of output, resulting in a 4/3 ratio or approximately 33% size increase. If the input length is not a multiple of 3, padding characters (=) are added to round up the output to a multiple of 4 characters. This overhead is the trade-off for being able to represent binary data using only printable ASCII characters.
How does this tool handle Unicode and special characters?
This tool uses the browser's built-in TextEncoder and TextDecoder APIs to properly handle Unicode text. When encoding, the text is first converted to UTF-8 bytes using TextEncoder, and then those bytes are Base64-encoded. When decoding, the Base64 string is decoded to bytes and then converted back to a UTF-8 string using TextDecoder. This ensures that multi-byte characters -- including emoji, Chinese/Japanese/Korean characters, Arabic, accented letters, and other non-ASCII text -- are correctly encoded and decoded without data loss or corruption.
What is a data URI and how is it used?
A data URI (also called a data URL) is a URI scheme that allows you to embed file content directly inline in HTML, CSS, or JavaScript. It follows the format data:[mediatype];base64,[data]. For example, a small PNG image can be embedded as data:image/png;base64,iVBORw0KGgo... directly in an <img> tag's src attribute or in a CSS background-image property. Data URIs eliminate the need for separate HTTP requests, which can improve performance for small files. However, they increase the document size due to Base64 overhead and bypass browser caching, so they are best suited for small assets like icons and simple graphics.
Is my data safe when using this tool?
Yes. This Base64 encoder/decoder runs entirely in your browser using JavaScript. No data is sent to any server, stored, or logged. All encoding and decoding operations happen locally on your device. You can verify this by disconnecting from the internet and confirming the tool still works. This makes it safe to use with API keys, configuration data, credentials, and other sensitive content -- though remember that Base64 is encoding, not encryption, so the output itself is not secure.

Explore More Developer Tools

Check out our other free developer tools. Decode JWTs, format JSON, parse cron expressions, and more -- all from your browser with no sign-up required.

JWT Decoder →