Base64 Encode & Decode
Convert text and files to Base64 and back — URL-safe, offline-capable, nothing leaves your browser.
- Runs in your browser — files never leave your device
- Features others lock behind paywalls
- More accurate results
Open a file to encode
Drop a file up to 8 MB, click to browse, or paste with Ctrl/Cmd+V
The result will appear here.How to use
- Choose Encode to turn text or a file into Base64, or Decode to turn Base64 back into text or a file.
- Paste text, a complete data: URI, or drop/click to open a file — up to 200,000 characters of text are saved in this browser so you don't lose your place.
- For encoding, pick Standard (+/) or URL-safe (-_) output, and toggle padding (=) on or off.
- Decoding accepts standard and URL-safe Base64 automatically, even mixed together or wrapped across multiple lines.
- Copy the result, or download it as a .txt (encode) or decoded file (decode).
- For a responsive tab, encode text or files up to 8 MB and decode Base64 inputs up to 12 MB.
Standard vs. URL-safe Base64
RFC 4648 defines two alphabets. Standard Base64 (section 4) uses + and / for its last two characters and is the form used in email (MIME) and most data: URIs. URL-safe Base64 (section 5), often called base64url, swaps those for - and _ so the output can go straight into a URL path, query string, filename or JSON Web Token (JWT) without percent-encoding.
Padding with = is optional in both, and many URL-safe contexts — JWTs included — omit it entirely because = has a reserved meaning in URLs. This tool lets you choose either alphabet when encoding, and decodes both automatically, even mixed together, without asking you to pick one first.
Why decoding here won't silently fail
Base64 input is invalid in exactly a few ways: a character outside the 64-symbol alphabet (plus - and _ for URL-safe), malformed '=' padding, a length that leaves a single leftover character — 6 bits, which can never form a full byte — or non-zero unused bits in the final character. The last rule prevents multiple different strings from silently decoding to the same bytes.
Many online decoders either show a generic "invalid input" message or silently return garbled bytes. This tool checks each case, reports the exact character and position that broke decoding, and tells you plainly if the decoded bytes aren't valid UTF-8 text, so you know to download them as a file instead of reading them as text.
Files, not just text
Dropping a file while encoding reads its raw bytes — any file type, not only images — and Base64-encodes them exactly like a data: URI or an email attachment would. You can also paste a complete data: URI (`data:…;base64,…`) to decode just its Base64 payload. Decoding always produces a byte-for-byte result you can download, whether or not it happens to be valid UTF-8 text; when it is, you can also read and copy it as text.
To prevent a giant result from freezing the tab, encoding is limited to 8 MB of source text or file data and decoding to 12 MB of Base64 input. Nothing is uploaded: conversion runs in a background worker in this tab using the File and TextDecoder APIs built into your browser.
Frequently asked questions
What's the difference between Base64 and URL-safe Base64?
Standard Base64 uses + and / as its last two symbols, which both have special meaning inside a URL and need percent-encoding there. URL-safe Base64 (base64url, RFC 4648 section 5) replaces them with - and _, which are safe in URLs, filenames and JWTs as-is.
Does decoding need me to know if the input is standard or URL-safe?
No — this tool's decoder accepts both alphabets in the same input, including a mix of the two, so you never have to pick a mode before pasting a Base64 string.
Can I paste a full data: URI?
Yes. Paste a value such as `data:text/plain;base64,SGVsbG8=` and the tool removes the header before decoding its Base64 payload. It also accepts plain Base64.
Can I Base64-encode a file, not just text?
Yes. Drop any file up to 8 MB onto the encode panel and it is read as raw bytes and encoded directly, the same way a browser encodes an image into a data: URI. The file never leaves your browser.
Why does Base64 make my data about 33% bigger?
Base64 packs 3 bytes (24 bits) of input into 4 output characters (6 bits each), so the output is always 4/3 — about 33% — longer than the input, before any padding.
What does the '=' padding at the end of a Base64 string mean?
Padding fills the last group of 4 characters when the input length isn't a multiple of 3 bytes. One '=' means the last group encoded 2 bytes; two '=' means it encoded 1 byte. Padding is optional and often omitted in URL-safe contexts like JWTs.
Why did decoding say the result isn't valid text?
The bytes you decoded aren't valid UTF-8 — most likely because the original data was a binary file (an image, a ZIP, etc.), not plain text. Use the download button to save the decoded bytes as a file instead.
Related tools
Updated 2026-10-13