Base64 Encoder/Decoder – Text & File, URL-Safe, MIME Line Breaks (Free Tool)

Base64 Encoder / Decoder A complete browser-based Base64 tool for text and files: devnestio.pages.dev/base64-tool/ Text mode — encode or decode any text string File mode — drag-and-drop or select a file to get its Base64 URL-safe mode — replaces + with - and / with _ MIME line breaks — inserts \n every 76 characters (RFC 2045) Character count for both input and output Copy buttons for instant clipboard copy Zero dependencies, instant results The tool correctly handles multi-byte characters (emoj
Base64 Encoder / Decoder
A complete browser-based Base64 tool for text and files: devnestio.pages.dev/base64-tool/
Features
- Text mode — encode or decode any text string
- File mode — drag-and-drop or select a file to get its Base64
-
URL-safe mode — replaces
+with-and/with_ -
MIME line breaks — inserts
\nevery 76 characters (RFC 2045) - Character count for both input and output
- Copy buttons for instant clipboard copy
- Zero dependencies, instant results
UTF-8 Handling
The tool correctly handles multi-byte characters (emoji, Japanese, etc.) by encoding through TextEncoder first:
function toBase64(str, urlSafe, lineBreaks) {
const bytes = new TextEncoder().encode(str);
let b64 = btoa(String.fromCharCode(...bytes));
if (urlSafe) b64 = b64.replace(/\+/g, '-').replace(/\//g, '_');
if (lineBreaks) b64 = b64.match(/.{1,76}/g).join('\n');
return b64;
}
Enter fullscreen mode Exit fullscreen mode
Decoding reverses through TextDecoder:
function fromBase64(b64, urlSafe) {
let s = b64.replace(/\s/g, '');
if (urlSafe) s = s.replace(/-/g, '+').replace(/_/g, '/');
while (s.length % 4 !== 0) s += '='; // auto-pad
const bytes = Buffer.from(s, 'base64');
return new TextDecoder().decode(bytes);
}
Enter fullscreen mode Exit fullscreen mode
Base64 Quick Facts
| Property | Value |
|---|---|
| Alphabet | A–Z, a–z, 0–9, +, / |
| URL-safe | A–Z, a–z, 0–9, -, _ |
| Padding | = (1 or 2 chars) |
| Size overhead | ~33% larger than input |
| MIME line length | 76 chars |
| Bits per char | 6 bits → 1 char |
Try It
devnestio.pages.dev/base64-tool/
Part of the DevNestio developer tools collection.


