FLXCode Base64 Encode and Decode

FLXCode apps

Appearance

Base64 Encode and Decode

Type text, paste Base64 or drop a file. Both boxes update as you go. It stays in your browser.

Drop any file here to turn it into Base64. Or paste text into either box.

Empty

Empty

Type or paste text, paste Base64, or drop a file. Nothing leaves this page.

No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it. What this tool keeps and sends.

Problem or idea? Email us

Quick start

  1. Type or paste text in the left box. The Base64 appears on the right.
  2. Paste Base64 in the right box to get the text back. Pasting Base64 into the left box works too, the page notices and decodes it. Undo puts your text back.
  3. To encode a file, drop it on the page or press Open file. To turn Base64 back into a file, paste it and press Download file.
  4. Tick As data: URI to get data:image/png;base64,... ready for an img tag or a CSS url().

What happens to what you paste

Nothing leaves the page. The work is done by JavaScript in your browser, files are read from your disk into memory and never sent anywhere. The address does not change, nothing is stored, and the usage counts we keep (details) hold a word like "encode", never your data.

Standard, URL-safe and wrapped

  • Standard (RFC 4648 section 4): + and / as characters 62 and 63, with = padding. Most APIs, data: URIs and PEM files.
  • URL-safe, called base64url (section 5): - and _, padding often left out. JWT tokens, URLs and file names.
  • MIME (RFC 2045): the standard alphabet in lines of 76 characters. Email attachments.

The wrap option puts a line feed after 76 characters. Decoding ignores line breaks and spaces anywhere, so wrapped text is fine in either box.

Errors

When the Base64 is not valid the page names the position, the line and column, and shows the text around it with a caret. The usual causes:

  • A character that is not in the alphabet, like a space inside a word, a quote, or an accented letter. Copy errors often add a quote or a trailing dot.
  • A length of 4n+1 characters. One character is always missing or extra, because a single character holds only 6 bits.
  • Both +/ and -_ in one text. A real encoder uses one alphabet.
  • = in the middle, or the wrong number of them at the end. Missing padding is accepted, wrong padding is not.

Files and pictures

The page reads the first bytes of decoded data to guess the type: PNG, JPEG, GIF, WebP, AVIF, BMP, ICO, SVG, PDF, ZIP, gzip, 7z, RAR, MP3, MP4, WAV, WASM, SQLite, fonts and a few more. If it is a picture, you see it. The saved file gets a matching extension. For anything unknown the file is saved as decoded.bin. The guess is from the bytes only. A ZIP also covers docx, xlsx, jar and apk files, so rename it if you know better.

Limits

Files up to 50 MB. No Base32 or hex, no encryption, no decoding of a URL from a link (that would need a request to another site). For a data: URI the page always uses the standard alphabet with padding on one line, as RFC 2397 expects, and switches the URL-safe and wrap options off. A Base64 file that is not UTF-8 text is shown as a file, not as text.

How it works

Text goes through TextEncoder to UTF-8 bytes. Every 3 bytes (24 bits) are split into four groups of 6 bits, and each group picks a character from a table of 64. Decoding reverses it. The tables, the padding rules and the error cases are checked in a test file against Node's own Base64 and the examples in RFC 4648 section 10.

FAQ

Is it safe to paste a token or a key here?

The text is handled in your browser and goes nowhere else. It is not put in the address, not stored and not part of the usage counts. Once the page has loaded, small texts convert even with Wi-Fi off. Still, keep the habit of pasting real secrets into as few places as you can.

Is Base64 encryption?

No. Anyone can decode it, no key is needed. It only turns bytes into plain letters and digits so they survive systems that expect text, like email, JSON or a URL. A Base64 password is a readable password.

Why does the output come out about a third longer?

Every 3 bytes become 4 characters, so the output is 4/3 of the input, plus up to 2 characters of padding. 3 MB of data becomes 4 MB of Base64. With the 76 character wrap option you add one line break per line as well.

What is the URL-safe option?

The URL-safe form (called base64url in RFC 4648) uses - and _ instead of + and /, and usually leaves out the = padding. It is what JWT tokens use, and it can sit in a URL or a file name without escaping. The page reads both forms when decoding and tells you which one it saw.

Why does btoa fail on my text?

The browser function btoa only takes characters up to code 255, so emoji or Polish letters throw an error. This page turns text into UTF-8 bytes first and encodes those bytes, so any Unicode text works. Decoding reads the bytes as UTF-8 again.

How big can the input be?

Text and files up to 50 MB. Work over 600 KB runs in a background worker so the page stays usable. Boxes that would hold more than 1 million characters show only the first 20,000, and Copy and .txt still use all of it.

More from FLXCode

  • JSON FormatterFormat, minify, sort and check JSON in your browser. Big numbers stay exact and errors show line and column.
  • Unix Timestamp ConverterEpoch seconds, milliseconds or nanoseconds to a date and back. Reads ISO 8601 and RFC 2822, any zone, whole lists.
  • UUID GeneratorMake version 4 or version 7 UUIDs in your browser, 1 to 1,000 at a time. Copy or download as .txt.
  • Password GeneratorMake a random password or passphrase in your browser. See the entropy and its formula. Nothing is sent.

Share Base64 Encode and Decode