Base64 Encoder & Decoder

Convert text to and from Base64 right in your browser — Unicode-safe, with URL-safe variants, padding and line-wrap control, plus file ↔ Base64 (data URI) conversion.

Type or paste text and the conversion runs live as you type. Encode with the standard or URL-safe alphabet, keep or strip = padding, and wrap long output for MIME emails. Decoding accepts both alphabets, padded or unpadded, and reports invalid characters with their exact position — and when the bytes are not text, you get a hex dump instead of mojibake. The File tab turns any file into Base64 or a full data: URI, and turns pasted Base64 back into a downloadable file with an image preview.

🔒 100% private — nothing is uploaded or stored. Your text and files are converted entirely in your browser with plain JavaScript. They never touch our servers, are never written to disk, and the page keeps working even if your internet connection drops.
Options apply to Encode and File → Base64.

Text → Base64

Type or paste text above — conversion runs as you type.

What is Base64?

Base64 is a family of binary-to-text encodings. It works by grouping the input into 24-bit chunks (three bytes) and splitting each chunk into four 6-bit values; each value picks one character from a 64-character alphabet — hence “Base64”. Because four characters are emitted for every three input bytes, the output is always about 33% larger than the input (plus up to two = padding characters).

Why does it exist?

The early internet only carried 7-bit ASCII, so any binary data — a photo, a font, a compiled program — had to be smuggled through text-only channels. Base64 does exactly that. You will meet it:

  • MIME email attachments (RFC 2045) — every binary attachment in an email is Base64 inside the .eml.
  • Data URIs — data:image/png;base64,iVBORw0KGgo… embeds a file directly in HTML or CSS.
  • JWTs — the header and payload of a JSON Web Token are URL-safe Base64.
  • HTTP Basic auth — Authorization: Basic dXNlcjpwYXNz is base64("user:pass").
  • API payloads and config files — certificates, keys and avatars pasted as strings.

Standard vs URL-safe

AlphabetCharactersUsed when
Standard (RFC 4648)A–Z a–z 0–9 + /Email, data URIs, most APIs
URL-safe (RFC 4648 §5)A–Z a–z 0–9 - _URLs, JWTs, file names — + and / are reserved characters in URLs

The two alphabets differ in exactly two characters (+// vs -/_). This tool decodes both interchangeably; the output option above picks which one to emit.

Padding

The final 24-bit group may contain only one or two bytes. Standard Base64 pads the output with = so its length is always a multiple of four:

  • "Hi" (2 bytes) → SGk=
  • "How" (3 bytes) → SG93 — no padding needed

Many URL schemes and APIs strip the padding. This tool can emit unpadded output, and its decoder accepts padded or unpadded input — it only complains when the padding contradicts the data length.

The UTF-8 gotcha

Base64 encodes bytes, not characters. If your text contains non-ASCII characters, the result depends on the character set: “café” is 5 bytes in UTF-8 (the é is C3 A9) but 4 bytes in Latin-1. Decode those UTF-8 bytes as Latin-1 and you get the classic mojibake “café”. This tool always treats text as UTF-8 — the same assumption browsers, JSON and modern APIs make.

Common pitfalls

  • Line wrapping. MIME wraps Base64 at 76 characters. Pasting wrapped output into a decoder that does not ignore newlines produces “invalid character” errors. This decoder ignores whitespace, and the encoder can wrap output for email.
  • Double encoding. Encoding an already-encoded string (or a string that already contains a data URI) produces a valid but useless result. If the output looks twice as long as it should, check you did not encode the encoding.
  • Binary vs text. The Base64 of an image is not a text file — round-tripping it through a text editor can insert a BOM or change line endings and corrupt it. Use the File tab for files.
  • Trailing garbage. A stray character after the padding — a quote copied from JSON, a counted newline — is the most common decode failure. The error message points at the exact position.

Want to do this from the command line instead? See the PowerShell Base64 encoding / decoding tech tip.

Nothing on this page leaves your browser: there is no server round-trip when you type, paste or drop a file, no analytics on your inputs, and no storage of any kind.


Luke Keam
Thank you for reading. Email me: [email protected]
Luke Keam | techgeek.biz