ToolsleFree tools · toolsle.com

Characters: 0

Characters: 0

Encode a File

Upload any file to get a Base64 data URL.

Decode to File

Paste a data URL or raw Base64, set a filename, then decode.

Advertisement

Base64 Encoder/Decoder

Base64 Encoder/Decoder — Encode and Decode Base64 Online

Our free Base64 encoder and decoder converts text and files to Base64 instantly — and decodes Base64 back to readable text or downloadable files. Everything runs in your browser using standard web APIs. No data is ever sent to a server. Supports Unicode text, URL-safe Base64, standard MIME line breaks, and file encoding for any file type.

What Is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data as a sequence of printable ASCII characters. The name comes from the 64 characters used in the encoding: uppercase A–Z (26 characters), lowercase a–z (26 characters), digits 0–9 (10 characters), and the symbols + and / (2 characters), plus = as a padding character.

Base64 encoding increases data size by approximately 33% — every 3 bytes of binary data become 4 Base64 characters. This size overhead is the trade-off for the ability to safely transmit binary data through text-only channels.

How Base64 Encoding Works

Base64 encoding works by taking binary data 3 bytes at a time (24 bits) and splitting it into four 6-bit groups. Each 6-bit group represents a value from 0 to 63, which is mapped to one of the 64 Base64 characters. If the input length is not divisible by 3, padding characters (=) are added to the end to make the output length a multiple of 4.

StepDescriptionExample
1Take 3 bytes of input"Man" = 77, 97, 110
2Convert to 24-bit binary010011010110000101101110
3Split into four 6-bit groups010011 010110 000101 101110
4Convert each to decimal19, 22, 5, 46
5Map to Base64 charactersT, W, F, u
6Result"TWFu"

Common Uses of Base64

Email Attachments

The MIME standard uses Base64 to encode binary email attachments. Since email was originally designed for 7-bit ASCII text only, binary files like images and documents must be encoded as Base64 text before being embedded in an email message. Your email client decodes them automatically.

Data URLs in HTML and CSS

Base64 encoding allows small images, fonts, and other binary assets to be embedded directly in HTML or CSS files as data URLs, eliminating separate HTTP requests. For example: <img src="data:image/png;base64,iVBORw0KGgo...">This technique is used for small icons and critical above-the-fold images to improve page load performance.

API Payloads and JSON

JSON does not support binary data natively. When APIs need to transmit binary content — such as file uploads, images, or cryptographic keys — inside a JSON payload, the binary data is Base64 encoded first. The receiving end decodes it back to binary.

Basic Authentication

HTTP Basic Authentication encodes credentials as Base64 in the Authorization header. For example, the username "user" and password "pass" are encoded as "dXNlcjpwYXNz" and sent in the header Authorization: Basic dXNlcjpwYXNz. Note that Base64 is encoding, not encryption — Basic Auth must always be used over HTTPS.

Storing Binary Data in Text Fields

Databases and configuration files that only support text values use Base64 to store binary data like encryption keys, certificates, and image thumbnails in string fields.

Advertisement

Base64 vs URL-Safe Base64

FeatureStandard Base64URL-Safe Base64
Character 62+- (hyphen)
Character 63/_ (underscore)
Padding== (sometimes omitted)
Safe in URLs?No — + and / need encodingYes
Safe in filenames?NoYes
RFCRFC 4648 §4RFC 4648 §5
Common useEmail, data URLs, generalJWTs, URL params, filenames

Base64 in Programming Languages

LanguageEncodeDecode
JavaScript (browser)btoa(str) for binary stringsatob(str)
JavaScript (Node.js)Buffer.from(str).toString('base64')Buffer.from(b64, 'base64').toString()
Pythonbase64.b64encode(bytes)base64.b64decode(string)
PHPbase64_encode($str)base64_decode($str)
JavaBase64.getEncoder().encodeToString(bytes)Base64.getDecoder().decode(string)
C#Convert.ToBase64String(bytes)Convert.FromBase64String(string)
RubyBase64.encode64(str)Base64.decode64(str)
Gobase64.StdEncoding.EncodeToString(bytes)base64.StdEncoding.DecodeString(string)

Frequently Asked Questions

Is Base64 the same as encryption?

No. Base64 is encoding, not encryption. Anyone can decode Base64 without a key — it is a reversible transformation designed for data compatibility, not security. Never use Base64 to protect sensitive data. Use proper encryption like AES for that purpose.

Why does Base64 end with == sometimes?

The = padding characters appear when the input length is not divisible by 3. One = means the last group had 2 bytes of input; two == means it had 1 byte. The padding ensures the output length is always a multiple of 4 characters.

How much does Base64 increase file size?

Base64 encoding increases file size by approximately 33%. Every 3 bytes of binary data become 4 Base64 characters. A 1MB image file becomes approximately 1.37MB when Base64 encoded.

What is the difference between Base64 and Base64URL?

Base64URL (URL-safe Base64) replaces the + character with - and the / character with _. This makes the encoded string safe to use directly in URLs and filenames without percent-encoding. It is used in JSON Web Tokens (JWTs) and many modern web APIs.

Can I encode any file type to Base64?

Yes. Base64 can encode any binary data regardless of file type — images, PDFs, audio files, executables, or any other format. The encoded output is always plain ASCII text.

Advertisement