
Base64 Encode/Decode: Text, Files and Images Online
Encode or decode text, a file, or an image as Base64 in the browser — data URIs, email attachments, JWT segments. 100% local, not encryption.
Why Base64 still shows up in every stack
A CSS background image that cannot load a separate file, a MIME attachment that must travel as ASCII, a JWT segment sitting between two dots, a WordPress option that was serialized then wrapped in Base64: none of these are encryption problems. They are transport problems. The online Base64 encoder and decoder turns Unicode text into an ASCII-safe alphabet and back, entirely in the tab. The image to Base64 converter does the same for a local PNG, JPEG, GIF, WebP or SVG file, as a data URI or as raw Base64. Nothing is uploaded. Base64 is not a hash, not a cipher and not a substitute for TLS. It is a way to carry bytes through channels that only accept letters, digits, +, / and padding. These tools sit together on the encoding tools hub.
When to encode in the browser, and when not to
The encoder is a scalpel for a string you can paste, not a CDN.
If the answer depends on a file the browser should not hold, or on cryptography, stay in CI or a secret manager.
The Base64 mistakes that burn an afternoon
Anyone who can read the string can decode it. Base64 has no key, no integrity check and no confidentiality. A token that looks opaque in a log is still plaintext after one decode. If the bytes must stay secret, encrypt them (or keep them out of the payload). If they must stay authentic, sign them with an HMAC or a JWT signature, not with Base64 itself.
RFC 4648 defines two alphabets. Standard Base64 uses + and / and usually keeps = padding. URL-safe Base64 (the JWT, cookie and path flavor) uses - and _ and typically drops padding. FastMinify's URL-safe option does both substitutions and omits padding on encode. On decode, URL-safe mode maps the alphabet back and restores the padding, while standard mode passes the string to atob unchanged: atob tolerates missing padding but rejects - and _. A URL-safe string with the option off is therefore an invalid-input error, and a standard string with the option on is still decoded, because those two characters are the only ones that get mapped.
A compact JWT is three Base64URL segments separated by dots, written header.payload.signature. The dots are not Base64. The Base64 tool decodes one alphabet string, not a dotted token. Its error message says so: paste only the encoded characters, with no dots. For a JWT, copy each part between the dots, or open the JWT decoder and inspect header and payload in one step.
Base64 expands binary data by about 33% (3 bytes become 4 ASCII characters). A 200 KiB JPEG becomes about 267 KiB of CSS. The image can then no longer be cached separately from the stylesheet, and it makes a stylesheet that already blocks rendering heavier. Over HTTP/2, extra requests are cheap, which removes the main reason to inline. Data URIs earn their keep for tiny icons that would otherwise cost a request. They lose for hero images, product photos and anything you already minify as a file.
Choose between standard Base64, URL-safe and data URI
The bytes do not change. The spelling does. Standard Base64 is what email MIME and most APIs emit. URL-safe Base64 is what JWTs, signed cookies and path segments need, so that + and / do not collide with query syntax. A data URI is standard Base64 with a data:<mime>;base64, prefix, so that a browser can treat the string as a resource.
Three tools, three inputs. The text encoder runs UTF-8 and then Base64 on a string, pasted or read from a text file. It will not interpret a PNG as pixels. The image converter reads file bytes and checks the MIME type. PNG, JPEG, GIF, WebP and SVG are accepted, and an empty MIME type is rejected rather than sniffed. It caps files at 32 MiB and emits a data URI or raw Base64. The preview uses an img element only: SVG is never injected into the DOM as markup. For SVG as CSS, with a choice between utf-8 and Base64 and a dedicated CSS snippet, use the SVG to data URI tool on the SVG hub. Its SVG input is capped at 512 KiB, a different limit for a different job.
Developers mash these together because they all "make a string safer". They solve different collisions. URL encode percent-encodes reserved URI characters. HTML entities escape markup so that a string can sit in an attribute. A hash (SHA-256, HMAC) provides one-way integrity or authenticity; see the hash and HMAC tools on the encoding hub, not this article. Base64 only changes how bytes are written.
What Base64 actually does to your bytes
Base64 takes 24 bits (3 bytes) and writes them as 4 characters from a 64-symbol alphabet. That is why the output is longer: 4/3, about 33% more, plus padding if the input length is not a multiple of 3. The overhead is the price of an alphabet that survives email, JSON strings and CSS. It is the opposite of minification. If the payload is JSON that you will ship over HTTP, minify the JSON first, then encode only if a wrapping layer requires ASCII; see the JSON minification guide.
Before
After
JavaScript's built-in btoa operates on a binary string (values 0–255). Pass it café, and it silently encodes the single Latin-1 byte for é instead of the two UTF-8 bytes; pass it an emoji or a CJK character, and it throws. FastMinify encodes the UTF-8 bytes with TextEncoder and then Base64, the same contract as Node Buffer.from(text, 'utf8').toString('base64'). Decoding reverses it with TextDecoder. Emoji and CJK survive. If you decode a blob that was never UTF-8 text (a PNG, a gzip stream), you get replacement characters, not a file. That blob belongs in image-to-base64 or a hex dump, not in a text field.
Before
After
When the byte length is not a multiple of 3, standard Base64 appends = or == so that the string length is a multiple of 4. URL-safe contexts (JWT, some cookies) omit that padding because = is a query delimiter. FastMinify URL-safe encode strips it; URL-safe decode puts it back before atob. Standard decode does not need it, because atob tolerates missing padding. Classic RFC examples: f → Zg==, fo → Zm8=, foo → Zm9v.
Before
After
Encode text, a file or an image in the tab
Open the Base64 encoder/decoder. Paste the text, or select a text file (the client limit is 32 MiB, like the other file pickers on the site). Choose Encode or Decode. Leave URL-safe off for MIME, data URI payloads and most API examples. Turn it on for JWT segments, signed cookie values and anything that will sit in a path. Load sample if you only want to see how it works. Everything stays in the tab.
1. Paste or select the source
Unicode text for encode; a Base64 alphabet string for decode. Do not include JWT dots or a data: prefix.
2. Set URL-safe to match where the string came from
With URL-safe on, the output uses a hyphen and an underscore and has no padding. With it off, the output uses plus and slash and keeps the = padding. A URL-safe string decoded with the option off is an error, not a partial decode.
3. Copy the result
If you decoded minified JSON, send it to the JSON formatter or the online JSON unminifier. They only change the layout, so names that were already lost stay lost.
Open the image to Base64 tool. Choose an image (PNG, JPEG, GIF, WebP or SVG, up to 32 MiB) or drop it onto the page. Choose Data URI for CSS url() and img src, or Raw Base64 to pass to another tool. The preview renders through an img element, and SVG is not mounted as DOM. Empty or unsupported MIME types are rejected because the tool does not guess. After a tiny icon, you can paste the URI into CSS. After a photograph, you usually should not.
Encoding is usually one step in a longer debugging session. The encoding hub groups the neighboring tools.
When the browser is enough, and when you still need a REPL
If the string already lives in a script, Node's Buffer matches FastMinify's UTF-8 then Base64 path. Use base64url when the consumer is a JWT library.
Basic example
The native btoa / atob pair is a binary-string API. Wrap it with TextEncoder/TextDecoder, or you will corrupt anything outside Latin-1. That wrap is what the FastMinify text tool already does.
Basic example
A local PEM, a binary fixture, or a CI job that must not open a browser: openssl stays the right tool. FastMinify will not replace a pipeline that already hashes or signs files on disk.
Basic example
No install, nothing uploaded, UTF-8 text plus a dedicated image converter with a 32 MiB cap and a URL-safe option. The limits: the text tool is not a binary file encoder, HEIC and PDF are out of scope for the image tool, and JWT verification is a different page. Use it to inspect, teach and unblock a machine without Node, then keep openssl or Buffer in CI.
Conclusion
Base64 is a boring, essential adapter: bytes in, an ASCII-safe alphabet out, 33% larger and fully reversible. FastMinify runs that adapter in the browser. It encodes UTF-8 text with an optional URL-safe alphabet, and a separate image converter (PNG, JPEG, GIF, WebP, SVG, 32 MiB) emits a data URI or raw Base64 without injecting SVG into the DOM. It does not encrypt, it does not hash, and it does not replace jwt-verify or a CDN. Encode the snippet, decode the log line, inline the icon, then stop. Start on the encoding tools hub, and open JWT decode when the string has two dots.
Encode or decode Base64 now
Related Articles

Paste a token and a JWKS to check an RS256, ES256 or HS256 signature in your browser. How kid picks the key, measured errors and the claims to check.

HTTP/2 and HTTP/3 change how files travel, not how big they are. Measured sizes, compile times and bundling tests show what minification still saves.

Convert a Unix epoch to a readable date and back, tell seconds from milliseconds, and avoid time zone, JWT and clock change traps, all in your browser.