QREndless

Base64 Encoder / Decoder

Unicode-safe encode & decode, instant both directions.

100% on-device
Mode
0 chars
Base64 output0 chars

Encoding UTF-8 text via TextEncoder → bytes → chunked btoa. Output Base64 is ~33% larger than the input.

Free online Base64 encoder and decoder converting text to and from Base64 strings

The Best Base64 Encoder / Decoder

UTF-8 Safe Encoding

Uses the standard TextEncoder/TextDecoder pipeline — never mangles emoji, CJK, or other multi-byte characters like the naive `btoa(unescape(encodeURIComponent(...)))` shortcut does.

100% Private

All encoding and decoding happens in your browser. No file is ever uploaded — your text and binary data never leave your device. No signup, no cookies.

Chunked Processing

Input bytes are processed in 32KB chunks (and Base64 in 4-aligned chunks) to avoid the "Maximum call stack exceeded" crash that hits naive `String.fromCharCode(...hugeArray)` on large files.

Text & File Mode

Encode raw text or any file (images, PDFs, ZIPs). For decoded binary content the file type is auto-detected from magic bytes and the right extension is suggested on download.

How to Use It in 3 Steps

  1. Choose Mode + Input

    Encode: paste text or drop a file (up to UTF-8 emoji and CJK safe). Decode: paste a Base64 string — whitespace is stripped automatically and the alphabet is validated.

  2. Convert Instantly

    Text and files are processed in 32 KB chunks in your browser — large inputs will not crash the call stack, and a 50 MB cap guards low-memory devices.

  3. Copy or Download

    Copy the Base64 (or decoded text) with one click. Binary results are format-sniffed from magic bytes — PNG, PDF, MP4, ZIP, and 20+ more — and offered as a download with the right extension.

Base64 Encoder / Decoder for Every Need

APIs & JSON Payloads

Encode credentials, tokens, and binary fields that must travel inside JSON. Decode response payloads to see what a server actually sent you.

HTTP Basic Auth

Build the Authorization header value: username:password encoded to Base64. The fastest way to test an endpoint with curl or Postman.

Email Attachments (MIME)

Email attachments ride inside messages as Base64. Decode a MIME block to recover the original file, or encode one to see what mail servers handle.

Data URIs for Images

Turn a small PNG, SVG, or favicon into data:image/png;base64,… and inline it in HTML or CSS — one fewer HTTP request, no broken asset paths.

Web Development

Inline fonts as Base64 in CSS, embed assets in single-file builds, or inspect JWTs and webhook payloads where the header and claims are Base64-encoded.

Debugging & Data Inspection

Staring at a Base64 blob in a log or database column? Decode it right here to reveal the JSON, text, or hidden binary inside before writing a script.

Complete Guide

Base64 Encoder/Decoder: The Complete A-to-Z Guide

How Base64 works, why UTF-8 handling matters for emoji and CJK, URL-safe variants, file encoding with format detection, and the errors you will actually hit.

What Is Base64 and What Is It For?

Base64 is a way to represent any binary data — text, images, ZIPs, anything — using only 64 safe printable characters: A–Z, a–z, 0–9, +, and /, with = for padding. It exists because many channels were built for text only: email (MIME), JSON, XML, HTTP headers, and URLs all choke on raw bytes. Base64 wraps binary in a text-safe envelope so it can ride through those systems untouched.

The trade-off is size: every 3 bytes become 4 characters, so Base64 data is about 33% larger than the original. That is the rent you pay for text-safety — worth it for an auth header, wasteful for a 4 MB hero image.

How Base64 Encoding Actually Works

The algorithm is satisfyingly mechanical: take the input in groups of 3 bytes (24 bits), split those into four 6-bit chunks, and map each 6-bit value (0–63) to one character of the alphabet. “Man” becomes TWFu: M=77, a=97, n=110 → binary 01001101 01100001 01101110 → 010011 010110 000101 101110 → T, W, F, u. When the input is not a multiple of 3, the last group gets zero-padded and one or two = characters pad the output to a multiple of 4 — which is why valid Base64 always has a length divisible by 4 (ignoring whitespace), a fact this tool checks for you on decode.

UTF-8: Why Emoji and CJK Break Naive Encoders

The classic bug: btoa("héllo") throws, and btoa("😀") produces garbage. JavaScript strings are UTF-16; btoa expects one byte per character. Naive fixes like btoa(unescape(encodeURIComponent(text))) work until they silently mangle multi-byte characters. This tool does it properly: TextEncoder converts your string to UTF-8 bytes first, then encodes those bytes, and decoding reverses through TextDecoder. Emoji, accented characters, Chinese, Japanese, Arabic — all round-trip exactly, which you can verify by decoding your own output.

Standard vs URL-Safe Base64

Standard Base64 uses + and /, both of which have special meanings in URLs and filenames. The URL-safe variant (RFC 4648 §5) swaps them for - and _ — that is what JWTs, URL parameters, and many APIs emit. This tool implements the standard alphabet and tells you clearly when it sees URL-safe input instead of failing mysteriously. Converting is trivial: replace - with + and _ with / (and re-pad with =) before pasting.

Encoding Files and Detecting the Original Format

Switch to file mode and any file becomes a Base64 string — the same encoding a JSON API would carry. Going the other way, the decoder sniffs the recovered bytes: magic numbers identify JPEG (FF D8 FF), PNG (89 50 4E 47), PDF (%PDF), ZIP/Office (PK), MP4, MP3, WebP, WOFF2 fonts, and 20+ more formats, while text-shaped data is checked for UTF-8 validity. You get a labeled result and a one-click download with the correct extension — no rename-the-.bin dance.

Base64 Is Encoding, Not Encryption

Worth engraving somewhere: Base64 provides zero secrecy. It is a reversible alphabet mapping that anyone can undo in milliseconds — “encrypted” passwords in a config file are not encrypted at all. Use Base64 to transport data safely through text-only channels, and use real cryptography (AES, proper key derivation, or your platform’s secret manager) to protect it. If you can read a credential after running it through this tool, so can anyone who has the file.

Common Base64 Errors and How to Fix Them

  • “Length is not a multiple of 4” — padding characters were lost, usually by a URL parser or spreadsheet. Re-add = until the length divides by 4.
  • “Characters outside the standard alphabet” — you pasted URL-safe Base64 (-/_) or a data: URI prefix. Strip the data:image/png;base64, prefix and convert the alphabet as described above.
  • Gibberish after decoding text — the bytes were never UTF-8 (a binary file, or a different encoding like Windows-1252). The tool detects this and offers a binary download instead of pretending it is text.
  • Newlines in the input — email/MIME Base64 wraps at 76 characters. This tool strips whitespace automatically, so wrapped input decodes fine.

Step-by-Step: Using the Base64 Encoder/Decoder

  1. Pick the direction. Encode (text or file → Base64) or Decode (Base64 → text or file), and toggle file mode if you are working with a file rather than typed text.
  2. Paste or drop your input. Encoding is live as you type (80 ms debounce); files are read entirely in your browser.
  3. Read the result. Text output appears directly; binary output is labeled with its detected format and size.
  4. Copy or download. Copy for API payloads and headers; download to recover the original file from a Base64 blob.
  5. Round-trip check. Encode a string, decode it back, confirm the match — the fastest way to trust an unfamiliar pipeline.

Ready to Encode or Decode?

You know how the 6-bit mapping works, why UTF-8 handling decides whether emoji survive, how to spot URL-safe variants, and what the tool does with binary payloads. Scroll back up, paste your input, and convert it in a keystroke — entirely in your browser, nothing uploaded.

Jump back to the Base64 encoder/decoder above ↑

Frequently Asked Questions

Everything you need to know about base64 encoder / decoder.
Is this Base64 encoder/decoder safe for non-ASCII text (emoji, Chinese, etc.)?

Yes. Encoding uses `new TextEncoder().encode(text)` (which produces UTF-8 bytes) before applying `btoa`, and decoding reverses this with `new TextDecoder().decode(bytes)`. This is the correct UTF-8-safe pipeline. The shortcut `btoa(unescape(encodeURIComponent(text)))` you see in many older tutorials also works, but is harder to read and easier to get wrong.

Can I encode or decode files (images, PDFs, ZIPs)?

Yes. Tick "Encode a file instead" to switch to file mode. For encoding, drop in any file — it is read as an ArrayBuffer and converted to Base64 in 32KB chunks. For decoding, paste the file's Base64 into the textarea and the tool will reconstruct the original bytes; the file type is auto-detected from its magic bytes and the correct extension is suggested when you click Download.

Why does large input sometimes crash other Base64 tools?

The most common cause is `String.fromCharCode(...new Uint8Array(buffer))` — spreading the entire byte array as function arguments blows the call stack once the buffer is bigger than ~64KB. This tool processes the input in 32KB chunks (and Base64 in chunks that are always a multiple of 4 characters to stay aligned) so very large inputs are handled without overflowing the stack.

Is there a size limit?

There is a 50MB soft cap on the output size to prevent out-of-memory crashes on mobile devices. If your input produces a larger output, the tool will still try to process it but will show a warning. The browser will be slow or may crash on very low-memory devices (older phones, tabs with many other sites open).

My Base64 has "-" and "_" instead of "+" and "/". What's wrong?

That's the "URL-safe" Base64 variant (RFC 4648 §5). This tool only accepts the standard alphabet (A–Z, a–z, 0–9, "+", "/", and "=" padding) and will show a friendly error if it sees "-" or "_". Convert URL-safe to standard first (replace "-" with "+" and "_" with "/") and decoding will work.

Is anything uploaded to a server?

No. The tool is 100% client-side. There are no API calls, no server actions, no analytics on your input. You can verify this by opening your browser's DevTools Network tab — you will see zero requests when you encode or decode, even for very large files.

Ready to use the Base64 Encoder / Decoder?

Open the tool