Base64 Encoder / Decoder

Encode and decode Base64 locally in your browser. Supports text conversion, URL-safe Base64, and file-to-Base64 export.

🔒 Zero network requests. Encoding happens entirely in your browser.

Formatter

0 bytes

File to Base64

Choose a file to encode it directly to Base64.

Copied!

You just tested your Base64 Encoder / Decoder — Try JWT Decoder next →

What Is a Base64 Encoder / Decoder?

The Base64 tool encodes bytes to ASCII and back per RFC 4648. The standard alphabet uses A-Z, a-z, 0-9 plus + and / as the 64 symbols, with = padding aligning the output to a 4-byte boundary. Length expansion is exactly 4/3 — every 3 input bytes become 4 output characters, so a 1024-byte file becomes a 1366-character string (rounded up for padding). The tool also supports base64url (RFC 4648 Section 5) which swaps + for - and / for _ and drops trailing =, making the output safe inside URLs, file names, and JWT segments without further escaping. Decoding accepts both alphabets and tolerates missing padding — useful for JWTs, which strip = for compactness. File mode reads any file with the browser's FileReader API, so PDFs, certificates, and signed binaries can be base64-encoded for embedding without leaving the tab.

How to Use the Base64 Tool

To encode, paste text into the input panel and choose Encode. To decode, paste a base64 (or base64url) string and choose Decode — the tool detects which alphabet you used. Toggle the URL-safe switch to force base64url output regardless of input alphabet. Drag a file onto the file zone (or use the picker) to encode binary data; the result includes the file's MIME type if known. The byte counter shows live input size so you can verify length expansion (output should be roughly 1.33x input). If decoding fails, the error pinpoints the first invalid character — usually a stray newline, a smart-quote, or a base64url string mis-classified as standard.

Why Base64 Encoding Is Everywhere

Base64 exists because the wire protocols that carry data — SMTP, JSON, HTTP headers, URLs — historically only guarantee a printable ASCII subset. Sending raw bytes risks corruption from intermediate proxies that interpret control characters or strip the high bit. Encoding trades a 33% size increase for safe transit, which is why MIME email attachments, PEM-wrapped certificates (-----BEGIN CERTIFICATE-----), and Data URIs (data:image/png;base64,...) all use the encoding. Choosing the right variant matters: standard base64 fits binary payloads in JSON or XML; base64url fits inside Authorization: Bearer <token> headers and JWT segments where the URL-unsafe + / would otherwise need percent-encoding. Cookies prefer base64url for the same reason — fewer characters to escape, fewer parser surprises across browsers and frameworks.

Frequently Asked Questions

What is URL-safe Base64?

URL-safe Base64 replaces + with -, / with _, and removes trailing = so the output is safer to place inside URLs.

Can I encode files?

Yes. Choose a file and the tool converts its bytes to Base64 locally, without uploading anything.

Why might decoding fail?

Decoding fails when the input is not valid Base64 or when the bytes do not represent valid UTF-8 text.