Base64 Encoder

Encode text or files to Base64 and decode Base64 back to plain text. Supports URL-safe Base64, line wrapping, and file encoding.

📝 Input Text
⚙️ Options
💡 Base64 increases size by ~33%. Use URL-safe variant (replaces +/= with -/_) for tokens, JWTs, and URL parameters.
☀️
Light
Step-by-Step Guide

Free Online Base64 Encode Online Tutorial

This tool encodes text or files to Base64 and decodes Base64 back to plain text. It supports URL-safe encoding, line wrapping, file uploads, and instant copy or download of results.

Base64 Encoder encode into base64 tool
1

Getting Started with the Online Base64 Encoder

The tool opens with a Text mode and File mode toggle at the top. In Text mode, a large monospace textarea accepts any plain text you want to encode or decode. As you type, three live counters in the input footer update in real time character count shows total typed length, byte size measures the data in UTF-8 encoding (important because some characters use multiple bytes), and line count tracks how many rows of text are present. These base64 encode online statistics give you immediate insight into your input size before you encode into base64. The input area supports multi-line content, making it suitable for paragraphs, code blocks, or configuration files.

format and inspect JSON data structures
A JSON viewer helps validate and explore structured data. Combined with Base64 decoding, you can inspect encoded API payloads with proper formatting.

Swap Button and Round-Trip Workflow

The Swap button is one of the most practical features for testing. After you encode into base64, clicking Swap moves the encoded result back into the input area. You can then click Decode to verify the round trip produces the original text. This lets you confirm encoding accuracy without manually copying and pasting between fields. The Swap button only works when a previous result exists if there is no encoded or decoded output stored, it does nothing. This feature is especially useful when testing different encoding options like URL-safe mode to verify the output decodes correctly regardless of the variant chosen.

Base64 Encoder Online Input and Configuration

Below the textarea sits the options panel with three configuration controls. The Variant dropdown selects between Standard Base64 and URL-safe Base64. The Line Wrap dropdown controls whether encoded output breaks at 64 or 76 characters or stays unwrapped. The Encoding dropdown switches between UTF-8 and Latin-1. The Example button loads a sample string with English and Unicode Arabic text to demonstrate multi-language support. The Clear button resets the input, hides the results panel, and clears any error messages giving you a completely fresh slate. These options make the online base64 encoder adaptable to different use cases ranging from web development to data processing.

Base64 URL Encode Variant Explained

URL-safe Base64 replaces + with - and / with _, and removes trailing = padding. This makes the encoded string safe for URL parameters, JWT tokens, and API endpoints. Standard Base64 uses + and / which can break URLs, so choosing the base64 url encode variant prevents data corruption in web contexts where special characters have meaning.

beautify and format JavaScript code
JavaScript developers frequently work with Base64 for encoding user data and API tokens. A JS formatter keeps your encoding logic clean and readable.
2

Using the Base64 Encode Decode Actions

Two large gradient action buttons sit below the options panel. The Encode to Base64 button converts input text into a Base64 string using the selected variant, wrap, and encoding settings. The Decode from Base64 button reverses the process, converting a valid Base64 string back into readable text. Both buttons validate input before processing encoding requires non-empty text while decoding checks for valid Base64 syntax. Invalid input triggers a descriptive error message. These base64 encode decode actions form the core workflow of the tool.

convert binary data back to readable text
Converting binary data to text is a related encoding task. A binary to text converter helps interpret raw binary sequences alongside Base64 operations.

How to Encode to Base64 from Text

When you click Encode, the tool converts your input text into bytes using the selected character encoding, groups them into 24-bit chunks, splits each into four 6-bit values, and maps each to a character from the Base64 alphabet containing A-Z, a-z, 0-9, +, and /. URL-safe mode substitutes - and _ for the last two. The output is about 33% larger than the input due to the 6-bit to 8-bit ratio. This is how the tool implements encode into base64 conversions.

transform ASCII characters into binary representation
An ASCII to binary converter translates text to binary form, helping you understand the lower-level data representation behind Base64 encoding.

Error Handling and Validation

The tool includes built-in validation for both operations. When you click Encode with an empty input, a browser alert reminds you to enter text first. When decoding, the tool checks if the input is valid Base64 syntax if the string contains invalid characters or incorrect length, a red error card appears below the input area with the title Warning Error and a detailed message explaining the issue. The error card is hidden automatically when a new successful operation completes or when you click Clear. Common mistakes include pasting regular text into the decode field, using the wrong variant, or including whitespace in Standard Base64 strings.

transform JSON data into XML format
A JSON to XML converter helps restructure data between formats. Combined with Base64, you can transport XML payloads safely through text-based protocols.

Base64 Encoding Online Statistics and Results

After a successful operation, four statistical cards appear showing Input Bytes, Output Bytes, Size Ratio, and Operation type. Input Bytes reflects the original data size. Output Bytes shows the encoded or decoded size. Size Ratio displays the proportional difference encode typically shows around 1.33x (the expected 33% overhead), while decode shows around 0.75x (the inverse compression). The Operation label clearly states whether the last action was Encode or Decode. These base64 encoding online stats help you understand the size implications of your encoding choices and verify the operation completed correctly.

URL encoder decoder
A URL encoder decoder handles percent-encoding for web addresses and complements URL-safe Base64 by ensuring data passes safely through query strings.
?

Frequently Asked Questions

What is Base64 encoding and why is it used?
+
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It is widely used for transmitting data over text-based media such as email attachments via MIME, storing complex data in JSON or XML, embedding images in HTML or CSS as data URIs, and encoding authentication tokens or API credentials. The 64-character alphabet ensures safe transmission across systems that may not handle raw binary correctly.
How do I encode text to Base64 using this tool?
+
Type or paste your text into the input textarea, select your preferred variant and encoding options, then click the Encode to Base64 button. The encoded result appears in the output section with size statistics. You can copy the output to clipboard or download it as a .b64 file. The tool handles Unicode text, special characters, and multi-line content without issues.
How do I decode Base64 back to readable text?
+
Paste the Base64 string into the input field and click Decode from Base64. The tool strips whitespace, handles URL-safe character substitutions, adds padding if needed, and converts back to the original text. Invalid Base64 triggers a clear error message. Use the Swap button to move a previously encoded result back to the input for decoding.
What is URL-safe Base64 and when should I use it?
+
URL-safe Base64 replaces + with -, / with _, and omits = padding. This makes the encoded string safe for URLs, query parameters, JSON Web Tokens, and API routes without percent-encoding. Use URL-safe mode whenever the encoded value will appear in web addresses or authentication headers to avoid corruption.
How do I encode a file or image to Base64?
+
Switch to File mode using the toggle at the top. Click the upload area to select any file type. The tool reads the file as a data URL and extracts the Base64 portion. File name, size, and type are displayed. URL-safe variant still applies. File encoding is useful for embedding images directly into HTML, CSS, or JSON payloads.
Why does Base64 increase data size by about 33%?
+
Base64 uses a 64-character alphabet where each character represents 6 bits. Original binary uses 8 bits per byte. The encoding groups three bytes (24 bits) into four Base64 characters (24 bits), creating a 3-to-4 ratio. Every three bytes of input produces four characters of output, resulting in a consistent 33% overhead across all implementations.
What does the line wrap option do?
+
Line Wrap inserts a newline after a specified number of characters in the encoded output. Choose no wrap, 64 characters, or 76 characters per line. Wrapping is useful for email systems with line length limits or configuration files. The wrap only affects encoding output decoding automatically ignores all whitespace.
How do I copy or download the encoded output?
+
The results panel includes Copy and Download buttons. Copy sends the entire output to clipboard with visual confirmation. Download creates a file encoded content saves as encoded.b64, decoded as decoded.txt. The Swap button moves the last result back to the input for further operations.
3

How to Base64 Encode File and Images

Click File Mode to switch from text to file encoding. A dashed upload area appears where you can browse or drop files. The tool accepts images, PDFs, text files, ZIP archives, and virtually any file type with a recommended maximum of 5MB. After selection, file name, size in kilobytes, and MIME type are displayed. The encode into base64 file reader converts contents into a Base64 data URL string using the FileReader API, making it available for copy or download.

🖼
convert PNG images to compressed JPG format
After encoding an image to Base64, converting between formats helps optimize file sizes for storage and web delivery.

Base64 Encode Image in File Mode

File encoding reads raw binary from the selected file. The resulting encode into base64 image string is longer than the original due to the 33% overhead. URL-safe variant applies here too. File encoding is especially useful for embedding images as data URIs the encoded string goes directly into an img src attribute, eliminating separate HTTP requests and improving page load performance.

encode URL parameters and query strings
A URL encoder handles special characters in web addresses. Using it with URL-safe Base64 ensures encoded data travels through web requests without corruption.

After selecting a file, the tool displays important details below the upload area the file name, size in kilobytes, and MIME type such as image/png, application/pdf, or text/plain. This confirmation helps you verify you selected the correct file before the encoding runs. The output for files is typically very long, so the output area includes vertical scroll support. For large files exceeding 5MB, the browser may experience slower performance since the FileReader processes the entire file in memory. For best results, use files under 5MB and be patient while larger files are encoded.

4

Understanding the Base64 Encoder Decoder Results

The output section displays results in a monospace code block with scroll support for long strings. Four action buttons sit below the output Copy sends the entire result to your clipboard and briefly changes its label to Copied! with a green background for visual confirmation. Download saves the result as a file encoded content uses the filename encoded.b64 and decoded content uses decoded.txt. The Swap button (available in the results panel) moves the output back to the input area for round-trip operations. Clear resets everything to start fresh. These Base64 Encoder decoder export options give you flexible ways to use the encoded or decoded data in your projects.

base64 encoder decoder
A dedicated Base64 Encoder decoder provides the same functionality with a different interface for encode and decode operations.

Practical Applications of Base64 Encoding

Base64 encoding serves many real-world purposes. Creating data URIs for images and fonts in CSS eliminates extra HTTP requests, improving page load speed. Encoding authentication tokens for API headers ensures safe transport across network boundaries without special character issues. Converting email attachments for MIME transmission allows binary files to travel through text-only email systems. Storing small binary blobs in JSON or configuration files avoids the need for sidecar files. The tool supports all these use cases with both text and file mode, Standard and URL-safe variants, and flexible line wrapping options. Each encoding choice affects the final output size and compatibility, so matching the variant and wrap setting to your specific use case is important for correct results.

◆ End of Tutorial ◆