Base64 Encoder
Encode text strings to Base64 format instantly and securely.
About Base64 Encoder
Base64 turns arbitrary bytes into a 64-character alphabet that survives systems which only promise to carry printable text. Paste text into the box above, press Encode, and you get the exact string that base64 on a Unix shell, Python's base64.b64encode or Java's Base64.getEncoder() would produce for the same bytes.
How the conversion actually works
Your text is first converted to UTF-8 bytes with the browser's TextEncoder. Those bytes are then read three at a time — 24 bits — and re-cut into four 6-bit groups, each of which indexes into the alphabet A–Z, a–z, 0–9, plus and slash. When the input length is not a multiple of three, one or two equals signs are appended so the result still divides evenly by four.
The UTF-8 step matters more than it sounds. The browser's raw btoa function reads a string as Latin-1 and throws on anything above U+00FF, so a naive implementation either rejects emoji outright or mangles accented characters. Encoding to bytes first is why é here gives w6k= rather than an error, and why the output matches a server that also works in UTF-8.
Where developers actually use it
The common cases are HTTP Basic authentication, where the encoded value is literally username:password; inline data URIs of the form data:text/plain;base64,…; embedding small payloads in YAML and JSON config where newlines and quotes would otherwise need escaping; and Kubernetes Secrets, whose data fields are Base64 by definition rather than by encryption.
What this page does not do
There is no file upload, no URL-safe toggle and no line-wrapping option — the result is one continuous line using the standard alphabet. If a downstream system expects the URL-safe variant, swap plus for hyphen and slash for underscore and drop the padding. If it expects PEM-style 64-column blocks, you will need to insert the line breaks yourself. To go the other way, the Base64 Decoder accepts this output unchanged.
UTF-8 Bytes, Not Code Units
Text is run through TextEncoder before encoding, so "é" becomes w6k= and "😂" becomes 8J+Ygg== — byte-for-byte identical to base64 on a Linux shell or Python’s b64encode.
Standard Alphabet, One Long Line
Output uses A–Z, a–z, 0–9, plus and slash, padded with equals signs, and is emitted as a single unbroken line with no 76-column MIME wrapping to strip out later.
Nothing Is Uploaded
The encoder is a few lines of JavaScript running in this tab. Open DevTools and watch the Network panel while you click Encode: no request is made, because there is no endpoint to call.
Frequently Asked Questions
Why is my encoded text about a third larger than the original?
Base64 spends four output characters on every three input bytes, so the result is always about 33% longer, plus up to two padding characters. A 1 MB input becomes roughly 1.33 MB. That overhead is the price of moving arbitrary bytes through a channel that only guarantees safe handling of printable text, which is why Base64 belongs in email attachments and data URIs but not in a storage format you control.
Is Base64 a form of encryption?
No, and treating it as one is a common and serious mistake. Base64 is a reversible transcoding with no key: anyone who sees the string can recover the original in one step. If you need something an observer cannot read, use the Encrypt Text tool, which applies a passphrase. If you need a value that cannot be reversed at all, use the Hash Generator instead.
Can I paste this into a URL or a filename?
Not safely. The standard alphabet contains plus and slash, and the padding character is equals — all three carry meaning in query strings and paths. A plus sign in a URL query is commonly read as a space, which silently corrupts the value. Either percent-encode the result with the URL Encoder, or hand-convert to the URL-safe variant by replacing plus with hyphen and slash with underscore.
Can I encode an image or a PDF here?
No. This page has a text box and no file picker, so it only encodes what you type or paste. To build a data URI from a real file you need a tool that reads the raw bytes rather than a string. Pasting the visible contents of a binary file into the box will not work either, because that text is already a lossy rendering of the bytes.
What happens to characters my keyboard cannot produce?
Anything expressible as valid Unicode encodes cleanly, including CJK text, combining accents and emoji. The one edge case is an unpaired surrogate — half of an emoji copied out of a broken log file. TextEncoder replaces it with U+FFFD, so those three bytes (EF BF BD) appear in the output and the round trip returns a question-mark diamond rather than the original fragment.
Will this output match what my server produced?
It will, provided both sides encoded the same bytes. Mismatches almost always come from an invisible difference in the input rather than from the encoder: a trailing newline, Windows CRLF line endings where the server had bare LF, or a byte-order mark at the start of a copied file. Compare the input lengths first — if they differ, the problem is upstream of Base64.