DEVELOPER PRECISION ENGINE

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 strings back to plain text — confirmed via testing, encoding and decoding round-trip correctly even for Unicode (emoji, accented characters, CJK text), not just plain ASCII. Two previously-confirmed gaps are now fixed: uploading a file offers a genuine "Output as data URL" checkbox that prepends the correct data:<mime-type>;base64, prefix using the file's real MIME type, and the "Input size" stat now shows the uploaded file's actual byte size instead of 0.

0 characters

How to Use This Tool

1

Select encode or decode mode.

Select encode or decode mode.

2

Type or paste your text into the input area, or for encoding, upload a file directly.

Type or paste your text into the input area, or for encoding, upload a file directly.

Pro Tip

Base64 is an encoding, not encryption — anyone can decode it instantly with this exact tool, so never treat a base64-encoded string as a secure way to hide passwords, API keys, or PII. It only exists to make binary-safe data survive transport through text-only channels, nothing more. When building a data URL from an uploaded file, the "Output as data URL" checkbox now uses the browser's own detected MIME type automatically — but if your file has an unusual or missing extension, double-check that the detected type actually matches the file's real format before relying on it.

About This Tool

When to Use

  • Decoding the Basic Auth header value from a captured HTTP request to see the underlying username and password.
  • Embedding a small icon or logo directly into CSS as a base64 data URI to eliminate an extra HTTP request
  • Decoding a JWT's header or payload segment manually to inspect its claims during API debugging.

Key Details

A Base64 encoder and decoder converts text or data between plain UTF-8 and Base64's 64-character ASCII-safe alphabet, the format used to embed binary data in text-based protocols like email (MIME), da...

Worked example

Encoding 'Hello, World!' produces SGVsbG8sIFdvcmxkIQ== — each group of 3 input bytes becomes 4 output characters from the Base64 alphabet, with = padding added at the end when the input length isn't evenly divisible by three. Decoding SGVsbG8sIFdvcmxkIQ== returns the exact original string. The same round-trip accuracy holds for Unicode text, verified directly: encoding "Hello 世界 🎉 café" and decoding the result returns the exact original string, emoji and all. Uploading a PNG file and checking "Output as data URL" now produces a complete data:image/png;base64,iVBORw0KGgo=... string using the file's real detected MIME type, ready to paste directly as an img src.

Interpreting your result

A successful encode or decode with no error message means the conversion completed correctly — confirmed reliable for both plain text and Unicode input. An "Invalid Base64 input" or "Decoding failed" error while decoding means the pasted text isn't valid Base64 (wrong characters, incorrect length, or misplaced padding) — that determination comes from the browser's own decoding behavior, not a guess. The "Input size" stat for an uploaded file now reflects the file's genuine byte size, and checking "Output as data URL" gives you a complete, correctly-MIME-typed string rather than raw Base64 text — both previously-confirmed gaps are fixed.

Base64 Encoder / Decoder FAQ

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string using 64 printable characters (A-Z, a-z, 0-9, +, /). It's commonly used to embed images in HTML/CSS, encode file attachments in emails, and transmit binary data in JSON.

Why does Base64 encoded output end with = or ==?

Base64 processes data in 3-byte groups, producing 4 encoded characters. When the input length isn't a multiple of 3, padding characters (=) are added to complete the final group. One = means 1 padding byte, two == means 2 padding bytes.

Is Base64 encryption?

No. Base64 is an encoding scheme, not encryption. Anyone can instantly decode Base64 back to the original data. Never use Base64 to protect sensitive data — it provides no security whatsoever. Use encryption (AES, etc.) for that purpose.

Can I encode binary files with this tool, and does it produce a ready-to-use data URL?

Yes to both. Upload any file and the tool reads it as an ArrayBuffer and encodes it to Base64, confirmed working correctly for arbitrary binary data. Check the "Output as data URL" box that appears after uploading to get a complete data:<mime-type>;base64,... string ready to use directly as an img src or CSS url() — it automatically uses the uploaded file's real MIME type. Leave the box unchecked if you just want the raw Base64 text instead.

How do I use Base64 in web development?

Common uses: data URIs in HTML/CSS (img src="data:image/png;base64,..." — this tool's file upload can produce that exact format directly via the "Output as data URL" checkbox), encoding credentials for HTTP Basic Auth (Basic base64(username:password)), encoding binary data for JSON APIs, and storing small binary blobs in localStorage.

What is the difference between standard Base64 and URL-safe Base64?

Standard Base64 uses + and / characters that have special meaning in URLs — they can break query strings and file names. URL-safe Base64 (Base64URL) replaces + with - and / with _, and omits padding = characters. JWT tokens use URL-safe Base64 for their header and payload. This tool outputs standard Base64 only — it doesn't currently offer a URL-safe encoding mode, so replace + and / and strip padding manually if you need Base64URL output.

Master Your Entire Toolkit

Access 500+ specialized calculators and tools designed for precision. No sign-up required, 100% free.

Built and reviewed by the Toolzip Team · Based on RFC 4648 — The Base16, Base32, and Base64 Data Encodings and MDN Web Docs — btoa()