🔄 Base64 Decode — Convert Base64 to Text Online
Decode any Base64 string back to plain text or download a file. Also encodes text and files to Base64. Free, instant, no signup.
Paste any Base64 string into the input area and click Decode. The tool instantly decodes it back to readable text. Switch to File mode to decode Base64-encoded files. Works for Base64-encoded images, PDFs, and any binary data.
How to Use
Choose mode
Select Text mode for plain text encoding/decoding, or File mode to encode any file.
Enter your input
Type or paste text, then click Encode or Decode. For files, drag and drop or click to browse.
Copy the output
Click Copy to copy the Base64 output to your clipboard for use in your project.
Frequently Asked Questions
Complete Guide: Base64 Encoder & Decoder
What Is Base64 and Why It Matters
Base64 is a binary-to-text encoding scheme that represents binary data using only 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It was designed in the 1980s to safely transmit binary content — images, executables, certificates — through text-only channels like email (MIME), HTTP headers, and XML documents that reject arbitrary bytes.
The most important thing to understand upfront: Base64 is encoding, not encryption. Anyone who has the Base64 string can trivially decode it. It provides zero confidentiality. Its only purpose is format compatibility — converting binary data into text that won't be corrupted by systems that mishandle raw bytes.
Where you encounter it daily: inline images in HTML or CSS (data:image/png;base64,…), HTTP Basic Authentication headers (Authorization: Basic dXNlcjpwYXNz), JSON Web Tokens (Base64url-encoded header and payload), email attachments encoded by MIME, and binary payloads in REST APIs that need to travel inside JSON fields.
How to Use This Base64 Tool
- Choose Text or File mode using the tabs at the top of the tool.
- Text mode: paste or type your text, then click Encode or Decode.
- File mode: drag-and-drop any file (image, PDF, font) onto the upload area. The encoded output appears instantly.
- Copy the output with the Copy button. For data URIs, use the "Copy as Data URI" option to get the full
data:prefix.
Code Examples
// Browser: encode/decode text
const encoded = btoa('Hello, World!'); // 'SGVsbG8sIFdvcmxkIQ=='
const decoded = atob('SGVsbG8sIFdvcmxkIQ=='); // 'Hello, World!'
// Node.js: encode a buffer (binary-safe)
const buf = Buffer.from('Hello, World!');
const b64 = buf.toString('base64'); // 'SGVsbG8sIFdvcmxkIQ=='
const back = Buffer.from(b64, 'base64').toString('utf-8');
// CSS: inline a small SVG icon as a data URI
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">...</svg>';
const dataUri = `data:image/svg+xml;base64,${btoa(svg)}`;
// background-image: url("data:image/svg+xml;base64,...")
// HTTP Basic Auth header
const credentials = btoa('username:password');
// Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
// Base64url (JWT-safe): replace + with -, / with _, strip padding
const b64url = btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
Common Mistakes to Avoid
- Treating Base64 as encryption — It is trivially reversible. Never use it to "hide" passwords, tokens, or sensitive data.
- Using
btoa()with non-ASCII text —btoa('日本語')throws aInvalidCharacterError. Encode to UTF-8 bytes first usingTextEncoder. - Confusing Base64 with Base64url — Standard Base64 uses
+,/, and=padding, all of which break URL parameters. JWTs and URL-safe contexts need Base64url (uses-,_, no padding). - Ignoring the 33% size overhead — Every 3 bytes of binary becomes 4 Base64 characters. A 1 MB image embedded as a data URI becomes ~1.37 MB in the HTML. Use sparingly for large assets.
- Embedding large images as data URIs — Breaks browser caching. The image re-downloads with every page load instead of being cached separately.
- Padding confusion — Base64 strings always have a length divisible by 4, padded with
=. Stripping or adding wrong padding causes decode failures.
Comparison with Alternatives
URL encoding (percent-encoding) is used for query string parameters — it encodes characters that are illegal in URLs (%20 for a space). Use it for URLs, not binary data. Hex encoding represents each byte as two hex digits; it's used for hashes, colors, and byte-level debugging, but produces 100% overhead vs Base64's 33%. Binary transfer via multipart form data is more efficient than Base64 for file uploads but requires the server to handle multipart parsing.
For image-to-Base64 conversion with a data URI preview, use the specialized Image to Base64 tool. For understanding JWT tokens that use Base64url encoding internally, see the JWT Decoder.
Pro Tips
- Small icons only for data URIs: Keep inline Base64 images under 2–3 KB. Above that, serve them as separate files and let the browser cache them.
- UTF-8-safe encoding in the browser:
btoa(unescape(encodeURIComponent(str)))is the classic approach; the modern way isbtoa(String.fromCharCode(...new TextEncoder().encode(str))). - Base64url for anything URL-adjacent: Any Base64 that could appear in a URL, cookie, or filename needs the URL-safe variant.
- MIME type prefix matters for data URIs:
data:image/png;base64,…anddata:image/jpeg;base64,…render as images;data:application/pdf;base64,…triggers PDF rendering in some browsers. - Check for accidental double-encoding: If your decoded output still looks like Base64 (all printable ASCII, length divisible by 4, ends with ==), you probably encoded twice.