How this Base64 encoder online handles UTF-8 text and btoa errors
Browser-native encoding turns raw bytes and Unicode strings into printable ASCII without sending API keys or payloads to a backend. Text is serialized to UTF-8 bytes before encoding, and pasted payloads are cleaned of whitespace and data: prefixes before decoding.
Fixing btoa Unicode errors with TextEncoder
Passing accented characters like wörld or symbols like ✓ directly into JavaScript’s btoa() throws a DOMException because btoa() rejects code points above 255. This encoder runs strings through the MDN Web Docs TextEncoder API first, converting every character into a standard UTF-8 Uint8Array before mapping 6-bit chunks to printable ASCII.
When you need to escape reserved characters inside query parameters rather than encoding binary payloads, use percent-encoding for query strings and full URLs instead.
Catching invalid characters and length remainder errors
During decoding, the parser trims surrounding spaces, strips any data:...;base64, header, and accepts both standard and URL-safe alphabets with or without = padding. If the cleaned string contains invalid characters or has a length % 4 === 1 remainder (impossible in valid 6-bit blocks), the tool pinpoints the exact offending character or truncation error.
Standard Base64 versus URL-safe Base64 and Base64 vs hex
Choosing the right binary-to-text alphabet prevents broken HTTP query strings and keeps payload bloat predictable. Checking URL-safe (- and _, no padding) switches between the two variants defined in IETF RFC 4648 Base64 Data Encodings.
When to enable URL-safe Base64 (- and _, no padding)
The standard alphabet (RFC 4648 Section 4) uses +, /, and =, all of which carry special meaning in URLs and shell arguments. Enabling URL-safe (- and _, no padding) applies RFC 4648 Section 5 (- instead of +, _ instead of /, and no trailing =), which is required for OAuth states and JSON Web Tokens.
If you are debugging an authorization token rather than raw strings, you can inspect Base64URL headers and claims inside a JWT directly.
Comparing Base64 vs hex size overhead
Grouping 6 bits per character (4 characters per 3 bytes) produces a 33% size expansion. Hexadecimal (Base16) encodes only 4 bits per character (2 characters per 1 byte), doubling payload size with a 100% overhead.
| Encoding format | Alphabet characters | Padding | Size overhead | Common use case |
|---|---|---|---|---|
| Standard alphabet (RFC 4648 §4) | A-Z, a-z, 0-9, +, / |
= |
~33% |
Email MIME, JSON fields, data: URLs |
| URL-safe alphabet (RFC 4648 §5) | A-Z, a-z, 0-9, -, _ |
Optional (stripped) | ~33% |
JWT segments, URL params, filenames |
| Hex / Base16 (RFC 4648 §8) | 0-9, a-f |
None | 100% |
SHA-256 hashes, raw byte dumps |
| UTF-8 Plain Text | Variable 1–4 bytes per char | None | 0% |
Source text before encoding |
Encoding files to data URLs and decoding Base64 to file downloads
Developers often convert small icons into inline stylesheets or recover attached PDFs and images from API logs. The file pipeline supports both directions cleanly in browser memory without touching an external server.
Creating RFC 2397 data URLs up to 25 MB
In Encode mode, Encode a file… accepts any local file up to 25,000,000 bytes (25 MB) and displays the exact byte expansion alongside Copy and Download (.b64.txt). Checking As a data: URL prepends data:<mime-type>;base64, and forces the standard alphabet (+, /, =) as required by the IETF RFC 2397 Data URL Scheme.
For responsive UI icons, you can minify SVG markup before embedding it as a data URL so the inline string stays as small as possible. Output previews truncate visually at 2,000,000 characters to keep the browser responsive while Copy and Download always export the complete string.
Tip: Avoid embedding multi-megabyte photos as
data:URLs in production CSS or HTML. Text encoding adds33%overhead and prevents browsers from caching the image separately from the stylesheet.
Magic-byte sniffing for decoded PNG, JPG, and PDF files
In Decode mode, binary payloads that fail UTF-8 text validation trigger a 12-byte magic-number check. The decoder recognizes PNG (89504e47), JPG (ffd8ff), GIF (GIF8), WebP (RIFF...WEBP), PDF (%PDF), ZIP (504b0304), and GZIP (1f8b), rendering a live preview for images and enabling Save decoded file with the matching extension.
When no known signature matches, the panel still lets you save the raw bytes as decoded.bin so custom binary blobs, protocol buffers, or compiled assets remain recoverable.
Why Base64 is encoding, not encryption, for secrets and manifests
Text encoding makes binary data safe for text-only protocols like JSON, email, and YAML, but it provides zero confidentiality. Anyone who intercepts an encoded string can reverse it instantly with no password or cryptographic key.
Client-side execution for API tokens and Kubernetes secrets
Because Kubernetes Secret manifests and HTTP Basic authorization headers store encoded credentials, pasting them into server-hosted converters risks leaking production keys into third-party logs. Running every calculation inside your browser tab ensures secrets never cross the network, and you can prepare YAML configuration manifests without uploading secrets in the same local workspace.
Strict UTF-8 validation on decoded output
When decoding text, the tool applies new TextDecoder("utf-8", { fatal: true }) in accordance with the MDN Web Docs TextDecoder API. Rather than silently replacing corrupted bytes with replacement characters, strict validation flags non-UTF-8 payloads immediately and routes them to the binary file download panel.
Large text inputs also offload automatically to a background Web Worker when supported, keeping typing and pasting responsive even on multi-megabyte payloads.