Base64 Encoder and Decoder
Input
Result
Encoded Base64 will appear here
Supports UTF-8, multi-byte characters, and large text
Session History
Instant Processing
Real-time encoding and decoding as you type. Web Worker for large files.
100% Private
All processing happens in your browser. No data is ever sent to a server.
Smart History
Session history with one-click restore. Auto-detects Base64 input.
About the Base64 Encoder
The Base64 Encoder encodes and decodes Base64, Base64URL (RFC 4648 Β§ 5), and hexadecimal β 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 5 MiB can be encoded as Base64 for embedding in data URIs, JSON payloads, or HTTP bodies. The tool runs entirely in your browser β your text and files never travel to any server, which matters when you are encoding API keys, JWT segments, or files that should not leave your network.
Updated: May 8, 2026
Related Tools
How to use the encoder
- Choose a direction: Encode (text/file β Base64) or Decode (Base64 β text). The input box adapts to the selected mode.
- For encoding, paste text or drop a file (up to 5 MiB). Toggle between standard Base64 (RFC 4648 Β§ 4 β the `+/=` alphabet) and Base64URL (Β§ 5 β the `-_` alphabet, used by JWT and many URL-safe protocols).
- For decoding, paste Base64 or Base64URL β the decoder auto-detects the alphabet and tolerates missing padding (some libraries omit `=` padding to save bytes).
- Hex mode encodes/decodes using the alphabet `0-9a-f`; useful for inspecting binary payloads side-by-side with a hex dump.
- Click Copy to drop the result into your clipboard, or Download to save large outputs as a file.
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 β the encoder lets you peek at any segment without reaching for a JWT-specific tool.
- 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. Text input flows through `TextEncoder`/`TextDecoder` for proper UTF-8 handling, then through a hand-rolled Base64 implementation that avoids `btoa`/`atob` (which mangle non-ASCII bytes). File input is read via the `FileReader` API; the bytes never leave your tab. URL state is not auto-synced, so refreshing the page clears the input. You can paste API keys, signed payloads, and proprietary binary blobs without exposing them.
Tips and pitfalls
- `btoa` chokes on non-ASCII. The native `btoa("hΓ©llo")` 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 accepts both; emit-side you should follow whatever the consumer expects.
- 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 half the density of 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.
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. Many real-world systems strip `=` padding to save bytes (Base64URL implementations, JWT segments). The decoder restores padding internally before decoding, so unpadded input works.
- What is the difference between Hex and Base64 encoding?
- Hex uses 2 characters per byte and the `0-9a-f` alphabet β twice 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.
- Can I encode any binary file?
- Up to 5 MiB. The encoder reads the file as an ArrayBuffer and emits Base64; 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. The encoder does not persist input to localStorage or to the URL by default. Refreshing the tab or closing it removes everything you pasted. Use the Share button if you explicitly want to encode the input into a sharable link (with lz-string compression for size).