Base64 Encoder and Decoder
Input
Result
Encoded Base64 will appear here
Supports UTF-8, multi-byte characters, and large text
History
Text conversions (input and output, last 50) are saved in this browser's localStorage until you click Clear All. They are not sent anywhere.
Instant Processing
Real-time encoding and decoding as you type. Web Worker for large files.
Runs in Your Browser
All processing happens in your browser. Nothing is uploaded for processing; text input is not saved in the page URL and goes into a link only when you click Share.
Smart History
History saved in this browser, with one-click restore. Auto-detects Base64 input.
About the Base64 Encoder
The Base64 Encoder encodes and decodes standard Base64 (RFC 4648 Β§ 4) β all client-side, with proper UTF-8 handling for non-ASCII text. Native `btoa` / `atob` only handle Latin-1; this tool wraps the input through `TextEncoder` so emoji, CJK, and accented characters round-trip cleanly. Files up to 50 MB can be encoded as a Base64 data URI for embedding in HTML, CSS, JSON payloads, or HTTP bodies, and a Base64 string or data URI can be decoded back into a downloadable file. Encoding runs entirely in your browser and nothing is sent to our servers or analytics, but each text conversion is kept in a local history in this browser, so avoid pasting live API keys or credentials. Text input is not written to the page address; it goes into a link only when you click Share.
Updated: May 8, 2026
Related Tools
How to use the encoder
- Choose Text or File mode, then a direction: Encode (text/file β Base64) or Decode (Base64 β text/file). In Text mode, input that looks like valid Base64 is flagged so you can switch to Decode.
- For encoding, paste text or drop a file (up to 50 MB). Output uses the standard Base64 alphabet (RFC 4648 Β§ 4 β `A-Z`, `a-z`, `0-9`, `+`, `/`, with `=` padding); files come out as a `data:` URI.
- For decoding, paste standard Base64. Base64URL input (with `-` and `_`) is not converted automatically β replace `-` with `+` and `_` with `/` first. In File mode you can paste a data URI and download the decoded file.
- Use Swap to feed the output back in as input with the direction reversed, or load a sample to see how the tool behaves.
- Click Copy to drop the result into your clipboard, or Save to download the output as a text file. Recent conversions appear in the history panel so you can restore them.
Common use cases
- Building data URIs. `data:image/png;base64,...` lets you inline small images, fonts, or SVG into HTML/CSS without an extra HTTP request β useful for tiny icons and email templates.
- Decoding JWT segments. JSON Web Tokens are three Base64URL-encoded segments β convert `-` to `+` and `_` to `/` and you can peek at a segment here, or use the JWT Decoder, which handles Base64URL directly.
- HTTP Basic auth. The `Authorization: Basic <base64(user:pass)>` header is one of the simplest auth schemes; encoding here gives you a ready-to-paste header value.
- Embedding small files in JSON. Some APIs accept Base64-encoded binary in JSON (image upload endpoints, signed URL shortcuts). The encoder produces a clean, copy-ready string.
- Debugging webhook payloads. Many webhook providers (Stripe, GitHub) sign payloads with HMAC and deliver Base64 signatures in headers β decoding lets you compare against your own HMAC computation.
Privacy and security
Encoding and decoding run entirely in your browser, and nothing is sent to our servers or analytics. Text input flows through `TextEncoder`/`TextDecoder` for proper UTF-8 handling, then through `btoa`/`atob` on the resulting bytes, so non-ASCII text is not mangled. File input is read via the `FileReader` API and is not saved anywhere. Text input is not written to the page address while you type, so it is not sent to our CDN on reload and does not stay in browser history; it goes into a link only when you click Share (lz-string compressed when long, which is not encryption). Each text conversion is also stored in this browser's localStorage history (up to 50 entries) until you clear it. Avoid pasting live API keys or credentials. A shared link stays in the recipient's browser history and in any app the link passes through.
Tips and pitfalls
- `btoa` chokes on non-ASCII. The native `btoa("hΓ©llo")` encodes Latin-1 instead of UTF-8 bytes, and `btoa("π")` throws InvalidCharacterError; this tool encodes the UTF-8 bytes correctly. Most "Base64 encoder" libraries that wrap `btoa` directly have the same bug.
- Base64URL replaces `+`, `/`, `=` with `-`, `_`, ``. Standards that embed Base64 in URLs (JWT, OAuth) use the URL-safe alphabet; pasting the wrong alphabet into a strict decoder produces a parse error.
- Padding is sometimes optional. RFC 4648 mandates `=` padding for length-mismatch alignment, but many real-world systems strip it. The decoder (the browser's `atob`) accepts unpadded input; the encoder always pads, so strip `=` yourself if the consumer expects unpadded output.
- Base64 inflates size by ~33%. Three input bytes become four output characters. Embedding a 1 MB image as Base64 ships ~1.33 MB of HTML; consider inline `<img>` with `loading="lazy"` and a real URL instead.
- Hex is less dense than Base64. Hex encoding produces two characters per input byte (vs four-per-three for Base64); use hex when you want human-readable output, Base64 when you want compactness. This tool outputs Base64 only.
Frequently Asked Questions
- When should I use Base64URL instead of standard Base64?
- Whenever the encoded value will be embedded in a URL, a JSON Web Token, or any context where `+`, `/`, or `=` would need percent-encoding. Base64URL replaces those characters with `-`, `_`, and (typically) no padding, so the result is URL-safe without further escaping.
- Does the encoder handle emoji and CJK characters?
- Yes. The tool routes text through `TextEncoder` to produce UTF-8 bytes before encoding, so emoji (π), CJK characters (μλ νμΈμ), and accented letters (cafΓ©) round-trip cleanly. Naive implementations using `btoa` directly fail on any non-Latin-1 input.
- How much overhead does Base64 add?
- Roughly 33% β every three input bytes become four output characters. Add line wrapping (some specs mandate 76-character lines) and the overhead grows slightly. For large binaries, native binary transports (multipart/form-data, `application/octet-stream`) are more efficient.
- Why is the output padded with `=`?
- Base64 encodes 24 input bits as 4 output characters. When the input length is not a multiple of 3, the encoder appends 1 or 2 `=` characters so the output length is always a multiple of 4. This makes streaming decoders and length checks easier β at the cost of a few bytes per message.
- Can the decoder handle Base64 without padding?
- Yes, for the standard alphabet. Many real-world systems strip `=` padding to save bytes. The decoder uses the browser's `atob`, which accepts unpadded input. Base64URL input (`-` and `_`) must be converted to `+` and `/` first.
- What is the difference between Hex and Base64 encoding?
- Hex uses 2 characters per byte and the `0-9a-f` alphabet β 1.5 times as long as Base64 but human-friendlier (you can spot byte boundaries). Base64 uses ~1.33 characters per byte across a 64-character alphabet β more compact, less readable. Both are reversible binary-to-text encodings; pick based on the consumer. This tool produces Base64 only.
- Can I encode any binary file?
- Up to 50 MB. The encoder reads the file with `FileReader` and emits a Base64 data URI; works for images, PDFs, ZIP archives, audio, anything. For larger files use a streaming command-line tool (`base64 input > output` on macOS / Linux, `[Convert]::ToBase64String((Get-Content -Raw -Encoding Byte input))` on Windows).
- Where can I read the standard?
- RFC 4648 covers Base64 (Β§ 4), Base64URL (Β§ 5), and Base32 / Base16 alphabets. MDN has practical examples for Web APIs (`btoa`, `atob`, `TextEncoder`). The JWT spec (RFC 7519) references RFC 4648 Β§ 5 for its segment encoding.
- Is the input field cleared on refresh?
- Yes, unless you restore it from history. Text input is not written to the page address, so a refresh starts empty; the Share button copies a link that includes it (lz-string compressed when long, which is not encryption). Each text conversion is kept in a local history in this browser's localStorage until you click Clear. File input is not saved. Clear the input and history before you leave if you pasted anything sensitive.