Base64 Encoder & Decoder Online

Encode text or files to Base64, or decode Base64 strings back to their original content. Supports standard and URL-safe Base64, multiple character encodings, and file drag-and-drop. Everything runs locally in your browser.

Drag & drop a file here to encode it to Base64, or click to browse
Input: 0 bytes
Encoded output will appear here...
Output: 0 bytes Ratio:

Core Capabilities

Lightning-Fast Processing

All encoding and decoding happens instantly in your browser using native JavaScript APIs. There is no server round-trip, no upload delay, and no file size limit imposed by a backend. Whether you are encoding a single line of text or a multi-megabyte binary file, the result appears in milliseconds. The tool leverages the browser's built-in btoa, atob, and FileReader APIs for maximum performance and reliability across all modern browsers and operating systems.

Complete Privacy

Your data never leaves your device. Every Base64 encoding and decoding operation is executed entirely on the client side, inside your web browser's JavaScript engine. No information is transmitted to any server, stored in any database, or logged anywhere. This makes the tool safe for encoding sensitive data such as API tokens, authentication headers, configuration secrets, or private documents. You can verify this by inspecting your browser's network tab while using the tool.

Versatile Encoding Options

Go beyond basic Base64 with full support for URL-safe encoding, multiple character encodings, and binary file handling. The URL-safe mode replaces + with - and / with _, and removes padding characters, making the output safe for use in URLs, filenames, and query parameters. Choose between UTF-8, ASCII, and ISO-8859-1 character encodings to handle international text correctly. Drag and drop any file type to generate its complete Base64 data URI representation.

Quick Start Guide

  1. Select your mode. Click the Encode tab to convert text or files into Base64 format, or click the Decode tab to convert a Base64 string back into readable text. Enable the URL-safe Base64 toggle if you need output that is safe for URLs and filenames, and select your preferred character encoding from the dropdown.
  2. Enter your data. Type or paste your content into the input textarea. For file encoding, drag and drop any file onto the upload zone or click to browse. The tool accepts all file types including images, PDFs, documents, and binary files. The byte size of your input updates in real time as you type.
  3. Process and copy. Click the Encode or Decode button to transform your data. The result appears instantly in the output area along with byte size statistics and the encoding ratio. Click Copy Output or the Copy button in the output area to send the result to your clipboard for use in your code, configuration, or any other application.
Pro Tip

Base64 encoding increases data size by exactly 33% — every 3 bytes of input become 4 characters of output. Keep this overhead in mind when embedding images or files as data URIs, and prefer this technique only for assets under a few kilobytes.

Common Mistake

Base64 is encoding, not encryption. It provides zero security — anyone can decode a Base64 string instantly. Never use Base64 to "protect" passwords, API keys, or sensitive data. Use proper encryption (AES, RSA) or hashing (bcrypt, Argon2) instead.

Use Cases & Examples

API Developer

Sarah builds microservices that exchange binary payloads over JSON APIs. She encodes images and PDF attachments to Base64 before embedding them in request bodies, ensuring binary data survives text-only transport layers without corruption.

Email Template Designer

James creates HTML email campaigns with inline images. He converts small logos and icons to Base64 data URIs so they display reliably across email clients without requiring external image hosting or dealing with blocked remote images.

Security Engineer

Lin inspects JWT tokens and HTTP Basic Auth headers daily. She decodes Base64 payloads to verify token claims, check expiration times, and audit authentication flows during penetration testing engagements.

Questions & Answers

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters. The standard Base64 alphabet consists of uppercase letters A through Z, lowercase letters a through z, digits 0 through 9, and the two symbols plus (+) and forward slash (/), with the equals sign (=) used for padding. Base64 encoding works by taking groups of three bytes (24 bits) and splitting them into four groups of six bits each. Each six-bit group is then mapped to one of the 64 characters in the alphabet. This process increases the size of the data by approximately 33 percent, but the resulting string contains only characters that are safe for transmission through text-based protocols such as email (MIME), HTTP headers, JSON payloads, and XML documents. Base64 was originally defined in RFC 4648 and has become an essential tool in web development, data serialization, and network communication.

What is URL-safe Base64 and when should I use it?

URL-safe Base64 is a variant of standard Base64 that replaces two characters in the encoding alphabet to make the output safe for inclusion in URLs, query parameters, and filenames. Specifically, the plus sign (+) is replaced with a hyphen (-), and the forward slash (/) is replaced with an underscore (_). Additionally, the trailing padding characters (=) are typically removed because they have special meaning in URL query strings. You should use URL-safe Base64 whenever the encoded string will appear in a URL path segment, a query parameter, a filename, a cookie value, or any other context where the standard Base64 characters plus, slash, and equals could cause parsing issues or require additional percent-encoding. Common use cases include JSON Web Tokens (JWTs), OAuth state parameters, secure file identifiers, and shortened URLs. This variant is defined in RFC 4648 Section 5 and is widely supported across programming languages and frameworks.

Why does Base64-encoded data become larger than the original?

Base64 encoding increases data size by approximately 33 percent because it represents every three bytes of input as four characters of output. Each input byte contains eight bits, so three bytes provide 24 bits total. Base64 divides these 24 bits into four groups of six bits, and each six-bit group maps to one ASCII character. Since the output uses only six out of eight possible bits per character, the encoding is inherently less space-efficient than raw binary. If the input length is not a multiple of three, padding characters (=) are added to complete the final four-character block, which can add one or two extra bytes. Despite this overhead, Base64 remains widely used because the trade-off is acceptable for the benefit of transmitting binary data safely through text-only channels. When data size is critical, consider using compression (such as gzip) before Base64 encoding to offset the expansion.

How do character encodings affect Base64 encoding?

Character encoding determines how text characters are converted into the bytes that Base64 then encodes. Different encodings produce different byte sequences for the same text, which results in different Base64 output. UTF-8 is the most common encoding on the web and supports every Unicode character. ASCII is a subset of UTF-8 that covers only the first 128 characters (English letters, digits, and basic punctuation). ISO-8859-1 (also known as Latin-1) covers 256 characters and includes accented characters used in Western European languages. If you encode text with accented characters or non-Latin scripts using ASCII, some characters may be lost or incorrectly represented. For maximum compatibility and correct handling of international text, UTF-8 is the recommended default. When decoding Base64, you must use the same encoding that was used during encoding to recover the original text correctly. Mismatched encodings are a common source of garbled text in decoded output.

Can I encode binary files like images and PDFs to Base64?

Yes, this tool fully supports encoding binary files of any type into Base64 format. Simply drag and drop your file onto the upload zone, or click the zone to open your file browser and select a file. The tool reads the file as raw binary data, encodes it to Base64, and generates a complete data URI that includes the file's MIME type. Data URIs follow the format data:[mediatype];base64,[data] and can be used directly in HTML image tags, CSS background properties, email attachments, and API payloads. This is particularly useful for embedding small images directly in HTML or CSS to reduce the number of HTTP requests, storing binary data in JSON or XML documents, and transmitting files through APIs that only accept text-based input. Keep in mind that the Base64 representation will be approximately 33 percent larger than the original file, so this approach works best for files under a few megabytes.

Is my data safe when using this Base64 tool?

Absolutely. This Base64 encoder and decoder runs entirely in your web browser. All processing is performed by JavaScript executing on your local machine, and no data is ever sent to any external server. Your input text, files, and output are never stored, logged, or transmitted over the network. This makes the tool completely safe for encoding sensitive information such as API keys, authentication tokens, private certificates, personal data, and confidential documents. Unlike many online Base64 tools that upload your data to a server for processing, Toolrip's implementation is genuinely client-side. You can verify this by disconnecting from the internet after loading the page — the tool continues to work perfectly because it does not depend on any server-side component. We believe that developer tools should respect user privacy by default, and local processing is the most reliable way to achieve that.

What are common use cases for Base64 encoding?

Base64 encoding is used extensively across software development and systems integration. In web development, it is commonly used to embed images and fonts directly in HTML and CSS files as data URIs, eliminating the need for separate HTTP requests. In API development, Base64 is the standard method for encoding binary data within JSON payloads, since JSON is a text-based format that cannot represent raw bytes. Email systems use Base64 (via MIME encoding) to attach binary files to messages that travel through text-only email protocols. Authentication systems such as HTTP Basic Authentication encode username and password pairs in Base64 before including them in request headers. JSON Web Tokens (JWTs) encode their header and payload sections using URL-safe Base64. Developers also use Base64 to store small binary blobs in databases, configuration files, and environment variables that only support string values. Data serialization formats frequently rely on Base64 when they need to include binary content within text-based documents.

How Base64 Encoding Works

Base64 converts binary data into a set of 64 printable ASCII characters. Understanding the encoding process helps you debug issues and estimate output sizes. Here is a step-by-step walkthrough of how the text "Hello" is encoded to Base64.

Step 1: Convert to ASCII Values
H=72 e=101 l=108 l=108 o=111

Each character is converted to its ASCII decimal value. This works identically for UTF-8 encoded text where each byte is processed individually.

Step 2: Convert to 8-bit Binary
01001000 01100101 01101100 01101100 01101111

Each ASCII value is represented as an 8-bit binary number. "Hello" produces 5 bytes = 40 bits total.

Step 3: Regroup into 6-bit Chunks
010010 000110 010101 101100 011011 000110 111100

The concatenated binary is split into 6-bit groups. Since 40 is not divisible by 6, the last group is padded with zeros (shown in color) to complete 42 bits (7 groups).

Step 4: Map to Base64 Alphabet
18=S 6=G 21=V 44=s 27=b 6=G 60=8

Each 6-bit value (0-63) maps to a character: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63). The values above produce the characters S, G, V, s, b, G, 8.

Step 5: Add Padding
SGVsbG8=

Base64 output must be a multiple of 4 characters. Since 7 characters were produced, one "=" pad character is appended. If the input had 1 byte remainder, two "=" pads would be added; if evenly divisible by 3, no padding is needed.

Size overhead: Base64 encoding always increases data size by approximately 33%. Every 3 input bytes become 4 output characters. For a 1 MB file, the Base64 representation will be roughly 1.33 MB. URL-safe Base64 replaces + with - and / with _ to avoid conflicts with URL reserved characters, but the encoding process is otherwise identical.

Similar Tools

Related Guides on Our Blog

Trusted Sources