dev-tools tool

Base64 Encoder / Decoder

Encode plain text or binary files to Base64 and decode Base64 strings back to text or files — entirely in your browser. Supports URL-safe encoding, MIME line breaks, file upload, drag and drop, and one-click copy as Data URI. No upload, no account, no limits.

Base64 Encoder & Decoder

Paste text or drop a file on the left to encode it to Base64. Paste a Base64 string to decode it back to text or download it as a binary file. Everything runs in your browser — nothing is sent to any server.

Paste or drop a file — mode auto-detects
Plain Text / File0 chars
Base64 Output0 chars
Quick Info
  • Base64 is a binary-to-text encoding scheme
  • Commonly used for data transmission
  • Increases size by about 33%
  • Use URL Safe for URLs and filenames

100% Private

All processing happens in your browser

No Limits

Encode and decode as much as you need

Secure

Your data never leaves your device

Free Tool

Completely free to use forever

About This Tool

Base64 Encoder & Decoder is a free browser-based tool for encoding and decoding Base64 strings. Paste plain text or drop any file into the input panel — the Base64 output appears instantly on the right. Everything runs in your browser. Your data is never sent to any server, API, or third party.

Auto-detect mode reads your input when you paste or drop a file and automatically switches between Encode and Decode. If the pasted content looks like a valid Base64 string, the tool switches to Decode mode. If it looks like plain text, it stays in Encode mode. You can override this at any time with the Encode / Decode toggle.

URL-safe encoding replaces + with -, / with _, and removes the = padding characters. This produces a Base64 string that is safe to use in URLs, query parameters, filenames, and HTTP headers — no percent-encoding required.

MIME line breaks insert a newline every 76 characters (configurable), producing the format required by email standards like RFC 2045 (MIME) and PEM certificate encoding. The line width is adjustable for any target format.

File encoding lets you upload any binary file — image, PDF, ZIP, font, audio — and convert it to a Base64 string. Use the Copy as Data URI button to get the complete data:{mime};base64,… URI, ready to paste into HTML, CSS, or JSON. Drag and drop a file directly onto the input panel — no file picker dialog needed.

File decoding works in the other direction: paste a Base64 string and click Download. The tool detects the file type from the decoded bytes (PNG, JPEG, PDF, ZIP, WebP) and downloads with the correct extension. The Swap button flips input and output and toggles the mode in one click — a workflow shortcut that most Base64 tools miss.

Size info below the panels shows input size, output size, and the percentage change. Encoding always produces output about 33% larger than the input — this is the fundamental trade-off of Base64.

How To Use

  1. 1. Select Encode or Decode mode with the toggle — or just paste and let the tool auto-detect.
  2. 2. Type or paste text in the input panel, or click File to upload a binary file for encoding.
  3. 3. Drag a file directly onto the input panel area to load it without the file picker.
  4. 4. The output appears automatically as you type. No button press required.
  5. 5. Enable URL Safe to replace + with - and / with _ — required for URLs and filenames.
  6. 6. Enable Line Breaks to insert newlines every 76 characters — required for MIME email encoding.
  7. 7. Click Copy to copy the output to clipboard, or Copy as Data URI (encode mode) to get a data:… URI.
  8. 8. Click Download to save the output — as a .base64.txt in encode mode, or decoded binary in decode mode.
  9. 9. Click (Swap) to move the output back into the input and flip the mode — useful for round-trip testing.
  10. 10. Click Clear in either panel to reset and start a new session.

What Makes This Base64 Tool Different

Most online Base64 tools are plain textareas with an encode button. This tool adds workflow features that cover real developer and designer use cases.

  • Auto-detect modeNo more clicking the wrong direction.
    Paste any content and the tool reads it — if it's valid Base64 it switches to Decode, if it's plain text it stays in Encode. No manual toggle required.
  • File encoding + Data URI copyThe big differentiator.
    Upload any binary file and copy the result as a complete data:{mime};base64,… URI. Paste directly into <img src>, CSS url(), or JSON config. No image hosting needed for small assets.
  • Drag & drop onto inputFaster than the file picker.
    Drop a file from Explorer or Finder onto the input panel — it loads instantly without opening a dialog.
  • URL-safe Base64Required for modern APIs and filenames.
    Replaces +// with -/_ and removes = padding, producing strings that are safe in URLs, query parameters, JWT tokens, and filenames without percent-encoding.
  • Swap buttonRound-trip testing in one click.
    Flips input and output, toggles the mode, and lets you verify encode → decode → original without copy-pasting between panels.
  • MIME line breaksEmail and PEM compatibility.
    Inserts a newline every N characters (default 76 per RFC 2045). Adjustable width for PEM (64 chars), MIME, or custom targets.
  • Binary file download on decodeRecover files from Base64.
    Paste a Base64-encoded image, PDF, or archive and click Download. The tool detects the file type from magic bytes and saves with the correct extension.
  • Size infoUnderstand the trade-off immediately.
    Input size, output size, and the size change percentage are shown below the panels. Encoding adds ~33%; decoding reduces by ~25%.

Frequently Asked Questions

Is my data sent to any server?

No. All encoding and decoding happens entirely in your browser using JavaScript. Your text and files are never sent to any server, API, or third-party service. The tool works fully offline after the first page load.

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It was designed to safely transmit binary data over channels that only handle text, such as email (MIME), JSON payloads, and HTTP headers. The trade-off is a ~33% increase in data size compared to the original binary.

What is URL-safe Base64?

Standard Base64 uses + and /, which are reserved characters in URLs and must be percent-encoded as %2B and %2F. URL-safe Base64 (RFC 4648) replaces + with - and / with _, and removes the = padding. The result is safe to use in URLs, query parameters, JWT tokens, and filenames with no further encoding.

How do I encode an image or file to Base64?

Click File in the input panel (or drag the file directly onto the panel). The file's binary content is encoded to Base64 and shown in the output. Click Copy as Data URI to get the complete data:{mime};base64,… string — ready to paste into an <img src> attribute, CSS background-image: url(), or a JSON field.

How do I decode Base64 back to a file?

Switch to Decode mode, paste the Base64 string into the input, and click Download in the output panel. The tool decodes the Base64 to binary, detects the file type from the decoded bytes (PNG, JPEG, PDF, ZIP, WebP), and downloads with the correct extension. If the file type cannot be detected, it downloads with a .bin extension.

Why does Base64 increase file size by 33%?

Base64 encodes every 3 bytes of binary data into 4 ASCII characters. 3 bytes = 24 bits; 4 Base64 characters = 4 × 6 bits = 24 bits. So the output is (4/3) = 1.333× the input size — approximately 33% larger. This is the fundamental trade-off: binary data becomes safe for text-only channels, but at a size cost.

What are line breaks used for?

MIME email standards (RFC 2045) require Base64-encoded data to be split into lines of no more than 76 characters. PEM format (used for SSL certificates and cryptographic keys) uses 64-character lines. Enable Line Breaks and set the width to 76 for MIME or 64 for PEM. The decoder in this tool automatically strips whitespace before decoding, so line-broken Base64 decodes correctly regardless.

What is a Data URI?

A Data URI (also called a data URL) is a URL scheme that embeds file content directly in the URI instead of linking to an external resource. Format: data:{mime-type};base64,{base64-data}. For example: data:image/png;base64,iVBOR.... Data URIs let you embed images, fonts, and other assets directly in HTML or CSS — eliminating an HTTP request. Use Copy as Data URI in encode mode to get the complete URI.

Does the tool handle UTF-8 and Unicode text?

Yes. The encoder uses the browser's TextEncoder API to convert text to UTF-8 bytes before encoding to Base64. The decoder uses TextDecoder to convert decoded bytes back to UTF-8 text. Emojis, CJK characters, Arabic, Hebrew, and all other Unicode text encode and decode correctly.

Is there a file size limit?

There is no enforced limit. The tool processes files entirely in your browser's memory. In practice, encoding large files (50 MB+) works but produces a very long Base64 string — around 67 MB of text — which may be slow to render in the output panel. For most use cases (images, PDFs, certificates, small archives), file sizes are well within range.