How this converter works
Two tabs, because the two jobs need different controls. The first takes text you type or paste; the second takes a file from your device. Each one runs in both directions, and the character-set list applies to both.
Everything is computed locally using the encoding APIs built into your browser. There is no upload step, no server round trip and no size limit beyond what your own machine can hold in memory. Disconnecting from the network does not stop the page working, which is the simplest way to confirm that claim for yourself.
encoded length = 4 × ⌈bytes ÷ 3⌉
growth ≈ 133% of the original size
What Base64 actually does
Computers store everything as bytes, and a byte can hold any of 256 values. Plenty of those values are not printable characters: control codes, byte sequences that no text encoding will accept, and values that particular systems treat as commands rather than content. Push raw bytes through a channel built for text and some of them will be mangled or rejected.
Base64 sidesteps the problem by refusing to use most of the range. It re-expresses the data using only 64 characters that survive anywhere: A–Z, a–z, 0–9, plus + and /. The information is unchanged and the process is perfectly reversible; what changes is that every character in the result is one no system will object to.
The trade is size. Sixty-four possibilities per character is six bits of information where a byte holds eight, so the same data needs more characters to express. That is the one third of extra length, and it is the price of safe passage.
The three-to-four rule, step by step
The whole algorithm fits in one sentence: take three bytes, lay their 24 bits in a row, cut the row into four pieces of six bits, and look each piece up in the alphabet. Following it through with the word Sun makes it concrete.
| Stage | S | u | n |
|---|---|---|---|
| Byte value | 83 | 117 | 110 |
| 8 bits each | 01010011 | 01110101 | 01101110 |
| 24 bits in a row: 010100 110111 010101 101110 | |||
| 6-bit values | 20, 55, 21, 46 | ||
| Characters | U 3 V u | ||
So Sun encodes to U3Vu. Longer input is the same operation repeated: the bytes are consumed three at a time until they run out. Nothing depends on what came before, so the same three bytes always produce the same four characters wherever they appear.
The alphabet itself is an ordered list. Values 0 to 25 are A to Z, 26 to 51 are a to z, 52 to 61 are 0 to 9, 62 is + and 63 is /. The step-by-step card above the article shows this working for whatever you have typed in.
Why some results end in equals signs
Data rarely arrives in a neat multiple of three bytes. When the final group is short, the remaining bits are still encoded and the output is topped up with = signs so that it divides evenly into fours. The pattern is fixed and tells you something about the original:
| Bytes in last group | Characters produced | Padding added | Example |
|---|---|---|---|
| 3 (full) | 4 | none | Sun → U3Vu |
| 2 | 3 | = | Su → U3U= |
| 1 | 2 | == | S → Uw== |
Because the padding only rounds out the length, some systems strip it; the URL-safe variant of Base64 usually drops it entirely. A decoder can work the length out regardless, which is why this page accepts strings whose padding has gone missing and decodes them anyway.
Character sets, and why decoding goes wrong
Here is the part that produces most of the confusion. Base64 encodes bytes. Text is not bytes until some character set has turned it into them, and the encoded string carries no record of which one was used.
The word café is four characters. In UTF-8 it is five bytes, because é takes two. In Windows-1252 it is four bytes. Those are different byte sequences, so they give different Base64 strings, and decoding one while expecting the other produces the familiar mess of question marks and replacement characters.
café in Windows-1252 → 63 61 66 E9 → Y2Fm6Q==
Forty character sets are offered here for exactly this reason, and the selection applies when encoding as well as when decoding. Plain ASCII text is identical in nearly all of them, so the choice only starts to matter once accents, Cyrillic, Greek, Hebrew, Arabic or CJK characters are involved. When in doubt, UTF-8 is the right answer: it is the default across the modern web and the one encoding that can represent every character.
Encoding files and images
The file tab reads a file from your device and converts its bytes with the same algorithm. Images are the common case, because a Base64 image can be embedded directly in a stylesheet or a page as a data URI instead of being fetched separately:
It saves a network request, which is worth having for a small icon. It is a poor trade for anything large: the data is a third bigger, it cannot be cached separately from the page that holds it, and it has to be re-downloaded every time that page changes. A few kilobytes is the usual sensible ceiling.
Decoding runs the other way. Paste a Base64 string, choose whether the result is text or binary, and the page hands back either readable text or a file to save. Nothing is uploaded in either direction.
Where Base64 turns up
- Email attachments. The original use. Mail servers were built for text, so MIME encodes every attachment this way.
- Data URIs. Small images, fonts and icons embedded straight into HTML or CSS.
- API payloads. JSON has no byte type, so binary fields travel as Base64 strings.
- Certificates and keys. The PEM format is Base64 wrapped in BEGIN and END lines.
- JSON web tokens. Each of the three segments is Base64 in its URL-safe variant. Note that the signature is what makes a token trustworthy, not the encoding.
- Basic HTTP authentication. The username and password are joined and encoded — which is precisely why that scheme is unsafe without HTTPS around it.
What Base64 is not
It is not encryption, not hashing, and not obfuscation worth the name. There is no key. Anyone who sees the string can recover the original in one step, using this page or any of a thousand others. The last two items in the list above are worth rereading with that in mind: a Basic authentication header is credentials in the clear, protected only by the transport underneath it.
The genuine use is transport safety, and it has nothing to do with secrecy. If something needs to stay private, it needs encryption before encoding, not instead of it.
What this page does not do
It handles standard Base64 with the + and / alphabet. The URL-safe variant that substitutes - and _ is not produced here, though strings using it will usually still decode. It does not decrypt anything, does not inspect or validate the contents of a decoded file, and does not interpret JSON web tokens beyond the encoding layer. For other conversions, our URL encoder and decoder covers percent-encoding and the hex calculator covers base 16.
Large files are limited by the memory your browser will give the page rather than by any fixed cap, and converting one may take a moment while it runs.
Frequently asked questions
What is Base64 used for?
It carries binary data through channels built for text. Email attachments, data URIs in CSS and HTML, certificates in PEM files, JSON web tokens and API payloads all use it, because each one is a place where raw bytes would be corrupted or rejected but printable characters pass through untouched.
Is Base64 a form of encryption?
No, and treating it as one is a real security mistake. Encoding is public and reversible by anyone — there is no key and no secret. A password in Base64 is a password in plain sight, readable by any decoder including this one.
Why is the encoded output longer than the original?
Base64 packs 3 bytes into 4 characters, so output grows by roughly a third. A 300 KB image becomes about 400 KB of text. Padding can add one or two more characters to round out the final group.
What do the equals signs at the end mean?
They are padding. Input is processed three bytes at a time, and when the last group is short the output is topped up to four characters with = signs. One leftover byte gives two equals signs, two leftover bytes give one, and an exact multiple of three gives none.
Why does my decoded text come out as question marks or boxes?
The bytes decoded correctly but were read with the wrong character set. Base64 carries bytes, not letters, so it cannot record which encoding produced them. Pick the matching character set from the list and decode again — UTF-8 is right in the large majority of cases.
Can I convert an image to Base64 here?
Yes. Switch to the file tab and choose encode, and any image becomes a Base64 string you can copy straight into a data URI. Decoding works the other way, turning a Base64 string back into a downloadable file.
Is my data sent anywhere?
No. The conversion runs entirely in your browser using built-in APIs. Nothing you type, paste or select leaves your device, which is why the page keeps working with the network disconnected.
This tool is provided for general technical and educational use. Base64 is an encoding, not a security measure, and it should never be relied on to protect passwords, keys or personal data. All conversion runs locally in your browser and nothing you enter is transmitted or stored. See our about page for how these tools are built and tested, and our privacy policy for what we do and do not collect.