Base64 is everywhere in modern development. It powers data URIs that embed images in CSS, encodes JSON API payloads, wraps email attachments, and forms the backbone of JWT tokens. Every developer encounters Base64 — and needs a fast, reliable way to encode and decode it.
That is why we built our free Base64 Tool. Paste any text and instantly encode it to Base64, or decode a Base64 string back to readable text. Drag and drop any file to convert it to Base64. All processing happens in your browser — no signup, no server, no data transmission.
What Is Base64?
Base64 is a binary-to-text encoding scheme defined in RFC 4648. It represents binary data using a set of 64 printable ASCII characters: A-Z, a-z, 0-9, +, and /. A padding character = is appended when the input length is not a multiple of three bytes.
Base64 does not compress or encrypt data. It simply re-encodes binary data as text. This makes it essential for systems that handle text but not raw binary — such as email protocols, JSON APIs, URLs, and HTML attributes.
The Base64 encoding process works in three steps:
- Split into bytes: The input data is treated as a stream of 8-bit bytes
- Group into 6-bit chunks: Three bytes (24 bits) are grouped into four 6-bit indices
- Map to characters: Each 6-bit index maps to one of the 64 characters in the Base64 alphabet
The result is approximately 33% larger than the original data — a necessary overhead for the text representation.
Standard vs URL-Safe Base64
Standard Base64 uses + and / characters. These have special meaning in URLs: + represents a space in query strings, and / is a path separator. Using standard Base64 in a URL without additional percent-encoding can cause corruption.
URL-safe Base64 (also called Base64url) solves this by replacing:
+with-/with_- Omitting padding
=characters
This variant is required by JWT tokens (RFC 7515), certain OAuth implementations, and any scenario where Base64 data travels inside a URL or filename. Our tool supports both standard and URL-safe encoding — toggle the checkbox before encoding or decoding.
What Our Base64 Tool Does
1. Text to Base64 Encoder
Paste any plain text and click Encode to Base64. The tool converts the text to UTF-8 bytes first, then encodes those bytes to Base64 using JavaScript's built-in btoa function with proper Unicode handling.
Example encoding:
Input: Hello World! 你好 🌍
Standard Base64: SGVsbG8gV29ybGQhIOS9oOWlvSDwn4yZ
URL-safe Base64: SGVsbG8gV29ybGQhIOS9oOWlvSDwn4yZ Enable the URL-safe Base64 checkbox to automatically replace + with - and / with _, and strip padding = characters.
2. Base64 to Text Decoder
Paste a Base64 string and click Decode from Base64. The tool validates the input, handles padding, and converts the result back to readable UTF-8 text. If your input uses URL-safe encoding, enable the checkbox so the tool correctly maps - back to + and _ back to / before decoding.
If the input is not valid Base64, the tool displays a clear error message instead of crashing or producing garbage output.
3. File to Base64 Encoder
Drag and drop any file — images, PDFs, audio files, archives — onto the drop zone, or click to browse. The tool reads the file using the browser's FileReader API and extracts the Base64 payload.
This is especially useful for:
- Creating data URIs for embedding small images directly in HTML or CSS
- Encoding file attachments for API requests that expect Base64 strings
- Converting binary data to a text-safe format for clipboard transfer
Files are processed entirely in your browser. Nothing is uploaded to a server. The tool supports files up to 10 MB.
How to Encode and Decode Base64: Step by Step
- Open the tool: Go to Base64 Tool
- Choose a mode: Click the Encode Text, Decode Text, or Encode File tab
- Enter your data: Paste text, paste a Base64 string, or drag a file onto the drop zone
- Toggle URL-safe if needed: Check the URL-safe Base64 checkbox for URL or filename use
- Click Encode or Decode: The result appears instantly below the input
- Copy the result: Use the copy button to copy the output to your clipboard
Common Base64 Use Cases
| Use Case | Why Base64? |
|---|---|
| Data URIs in HTML/CSS | Embed small images, fonts, or SVGs directly in stylesheets without separate HTTP requests |
| JSON API payloads | JSON is text-only; binary data (images, audio, PDFs) must be Base64-encoded to fit inside a JSON string |
| Email attachments (MIME) | SMTP is a text protocol; binary attachments are encoded as Base64 for transmission |
| Basic Authentication headers | The Authorization: Basic header encodes username:password as Base64 |
| JWT tokens | JSON Web Tokens use Base64url encoding for their header and payload segments |
| URL parameters | URL-safe Base64 encodes binary data in query strings without percent-encoding issues |
Base64 Encoding Size Reference
Because Base64 maps every 3 bytes to 4 characters, the encoded output is always approximately 33% larger than the original. Padding adds 0–2 characters at the end.
| Original Size | Base64 Output Size (approx) |
|---|---|
| 100 bytes | 134 characters |
| 1 KB | 1.37 KB |
| 10 KB | 13.7 KB |
| 1 MB | 1.37 MB |
How to Embed a Base64 Image in HTML
One of the most common developer tasks is converting a small image to Base64 and embedding it directly in HTML or CSS. Here is how:
- Encode your image file using our File to Base64 tool
- Copy the Base64 string
- Prefix it with the correct MIME type:
data:image/png;base64,(replacepngwith the actual format) - Use it as an
srcattribute:<img src="data:image/png;base64,iVBORw0...">
This technique eliminates an HTTP request for the image file. It works best for small icons and graphics under 2 KB. For larger images, a separate file with caching is usually more efficient.
Frequently Asked Questions
Is this Base64 tool free?
Yes, completely free. No signup, no usage limits, no API calls. Everything runs in your browser.
Does this tool send my data to a server?
No. All encoding, decoding, and file processing happens 100% client-side in your browser using JavaScript. Your data never leaves your machine. This makes it safe for sensitive files, credentials, and proprietary data.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 replaces them with - and _ and omits padding, making the output safe to use in URLs and filenames without additional encoding.
Can I encode files larger than 10 MB?
The file encoder works with files up to roughly 10 MB. Larger files may cause browser performance issues because the entire file is loaded into memory. For very large files, use a command-line tool like base64 on Unix systems or PowerShell on Windows.
Is Base64 encryption?
No. Base64 is an encoding, not encryption. It provides zero security or confidentiality — anyone can decode a Base64 string instantly. If you need to protect sensitive data, use proper encryption (such as AES) and never rely on Base64 alone.
Can I decode a Base64 string that contains Unicode or emoji?
Yes. Our decoder handles UTF-8 correctly, so emojis, Chinese characters, Arabic script, and all Unicode characters are restored accurately.
Does the tool add a data URI prefix for files?
No. The tool outputs the raw Base64 string only. If you need a data URI, manually prepend the MIME type prefix (for example, data:image/png;base64,) to the output.
Try It Now
No signup, no installation, no server calls. Open Base64 Tool, paste your text, and encode or decode it instantly. Convert files to Base64 with drag-and-drop.
Looking for more free developer tools? Browse our full tools directory — including URL Encoder/Decoder, JSON Formatter, and JWT Decoder.