Base64 Encoder and Decoder
Table of Contents
Base64 Encoder & Decoder — encode or decode Base64 online
Base64 Encoder & Decoder — encode or decode Base64 online
Working on: bae64
PicoToolkit encodes text to Base64 and decodes Base64 back to UTF‑8 text. The tool supports the standard and URL‑safe Base64 variants. All conversion runs client‑side (no file upload) and nothing is sent to the server — safe to use for quick text transforms (but remember Base64 is not encryption).
How to use
- Paste text or a Base64 string into the editor.
- Choose mode: Encode or Decode.
- Toggle URL‑safe if you need a URL/filename friendly output (- and _ instead of + and /).
- Choose whether to include padding when encoding (default: include =). The decoder accepts strings with or without padding.
- Click Convert → Base64. Copy the result from the output area.
Behavior & rules (short)
- Input encoding: text input is encoded/decoded as UTF‑8. Decoding produces UTF‑8 text when bytes are valid UTF‑8.
- Standard vs URL‑safe: standard Base64 uses + and /; URL‑safe replaces those with - and _. The tool supports both and can toggle the variant for encoding. Decoding accepts either form (it normalizes URL‑safe to standard before decoding).
- Padding: encoded output includes = padding by default. The decoder accepts inputs with or without padding.
- Binary/files: the current tool works with pasted text only (no file upload). To encode a file, open it locally and paste its binary/text representation or use a local encoder.
- Error handling: malformed Base64 input produces a clear decode error message; ensure the string is valid Base64 (correct length and characters).
- Client side: conversions run in the browser — data is not uploaded (see privacy note below).
Examples (copy/paste)
Example A — simple text → Base64
Input (text): hello Output (standard Base64): aGVsbG8=
Example B — UTF‑8 text with diacritics
Input (text): café Output (standard Base64): Y2Fmw6k= (UTF‑8 bytes: 63 61 66 c3 a9 → encoded as shown)
Example C — decode Base64 → text
Input (Base64): aGVsbG8= Output (text): hello
Example D — URL‑safe variant
Input (text): foo/bar+baz Output (standard Base64): Zm9vL2JhcitibWF6 Output (URL‑safe Base64): Zm9vL2JhcitibWF6 (same bytes; display replaces +/ with -_ if present) Note: when + or / appear in standard Base64 they become - and _ in URL‑safe form; padding '=' may be omitted.
Security & privacy
- Base64 is reversible encoding, not encryption. Do not use it to protect secrets.
- All conversions run client‑side in your browser. The tool does not upload input text or results to the server. If you need stronger guarantees, verify the privacy statement in the site footer.
- For large or sensitive binary files, prefer local command‑line tools or trusted desktop apps rather than pasting raw data into a web page.
Developer & command‑line snippets
- Linux / macOS (coreutils):
echo -n "hello" | base64 # decode: echo 'aGVsbG8=' | base64 --decode
- Node.js:
Buffer.from('hello', 'utf8').toString('base64') // encode Buffer.from('aGVsbG8=', 'base64').toString('utf8') // decode - Browser (UTF‑8-safe):
// encode const enc = new TextEncoder(); const bytes = enc.encode('café'); let b64 = btoa(String.fromCharCode(...bytes)); // decode const str = atob(b64); const dec = new TextDecoder(); const out = dec.decode(Uint8Array.from(str, c => c.charCodeAt(0))); // Note: using TextEncoder/TextDecoder avoids btoa/atob UTF‑8 limitations.
Tips & troubleshooting
- If decoding fails, check that the string contains only Base64 characters (A–Z a–z 0–9 + / - _ and optional = padding) and that length is correct (mod 4).
- Use the URL‑safe toggle when embedding Base64 in query strings, filenames, or route parameters.
- To embed small images in HTML/CSS you can create a data URI locally (data:image/png;base64,...) — this tool handles text only via copy/paste.
- For exact binary-to‑Base64 (files), use local tools (openssl base64, base64 CLI, or programmatic methods above) to avoid character/encoding issues.
Related tools
- URL Encoder — encode data for safe URLs.
- Escape HTML — escape characters before embedding into HTML.
- Text to HTML — prepare text before encoding.
FAQ
Does the tool support URL‑safe Base64?
Yes. The encoder can produce URL‑safe output (replacing + with - and / with _). The decoder accepts both standard and URL‑safe inputs.
Can I encode binary files here?
No. The web tool accepts pasted text only. For file encoding, use local command‑line utilities or read the file and paste a textual representation if appropriate.
Is Base64 secure?
No. Base64 is an encoding, not encryption. Anyone can decode it back to the original bytes. Use proper encryption for sensitive data.