Base64 Encode
Encode text to Base64, right in your browser. No uploads.
What is Base64 Encode
Base64 encoding represents text or binary data using 64 characters (A-Z, a-z, 0-9, +, /). It is commonly used for email attachments and data URLs.
🔒 Everything runs in your browser. Nothing is uploaded.
What this tool actually does with your file
- Where it runs
- In your browser, on this page
- Upload
- None — the file never leaves your device
- Offline
- Works with the network disconnected
What Base64 actually does to your bytes
The text is first converted to UTF-8 bytes, then every three bytes are cut into four 6-bit groups and mapped onto the alphabet A–Z a–z 0–9 + /. When the input length is not a multiple of three, the tail is padded with one or two = signs so the output length stays a multiple of four. That is RFC 4648 section 4, and it is the only thing happening here — no compression, no encryption, no verification.
This browser API is the reason the byte step matters: btoa() accepts Latin-1 only and throws InvalidCharacterError the moment it meets a character above U+00FF. So every correct implementation converts to bytes first. A Chinese character costs three UTF-8 bytes, which become four Base64 characters; a plain ASCII letter costs one byte and lands on roughly 1.33 characters.
Where the + / = alphabet bites
Base64 output goes up by about a third, so a 3 MB file becomes a 4 MB string. If you are putting this into a URL, a filename or a JSON Web Token, the standard alphabet will be mangled: + turns into a space in a query string, / collides with path separators, and = confuses some routers. Use the URL-safe variant instead (- and _ with the padding dropped), which is what JWT does.
The other recurring mistake is treating the output as protection. Base64 is a transport encoding: anyone can decode it in one line, including anyone who intercepts it. If you need confidentiality the primitive is encryption with a key, and if you need tamper evidence it is an HMAC — not a longer alphabet.
When the output is not what a decoder expects
Line breaks are the usual culprit. Some tools wrap at 76 characters for MIME mail, others emit one unbroken line. Decoders that follow the spec ignore whitespace, but stricter ones (and many language runtimes' strict modes) reject it. If a downstream service says the Base64 is invalid while this page produced it, compare the two strings for wrapped lines before assuming corruption.
Trailing = padding is also frequently stripped by intermediaries, and while a tolerant decoder can reconstruct it, a strict one cannot. If you control both ends, keep the padding and keep the alphabet consistent — mixing standard and URL-safe Base64 across a pipeline fails silently more often than it fails loudly.
How to use it
- 1.Enter your text
- 2.Click Convert
- 3.Copy the result
How Base64 Encode works under the hood
Encoding tools convert between representations of the same bytes: Base64, percent-encoding, hex, HTML entities, Unicode escapes. A correct encoder is reversible; a lossy one silently changes the data.
- 1
Get the exact bytes
Text is encoded to UTF-8 bytes with TextEncoder first; binary input is read as an ArrayBuffer. Encoding the wrong byte sequence is the most common cause of a wrong result.
- 2
Apply the encoding rule
Each format has an exact specification: Base64 uses a 64-symbol alphabet with padding, percent-encoding escapes reserved characters as UTF-8 bytes.
- 3
Decode back to verify
Round-tripping the output back to the input is the only honest proof that an encoder is correct. The tool keeps the reverse path available on the same page.
Processing pipeline
Text is first converted to UTF-8 bytes, then encoded — each CJK character is 3 bytes, which is why the highlighted Base64 for "Hello, 世界" is much longer than the input and ends with one = padding. URL-encoding escapes every byte as %XX, so one CJK character becomes nine characters; the characters that actually break query strings are =, & and space, all of which are escaped here.
Base64 is not encryption
Base64 increases size by about a third and hides nothing: anyone can decode it. It exists to carry binary data through text-only channels such as JSON, email headers and data URLs. If you need confidentiality, use encryption with a key, not an encoding.
Where encoders break
Percent-encoding applied twice turns %20 into %2520; Base64 without padding fails strict decoders; UTF-16 input decoded as UTF-8 produces replacement characters that cannot be recovered. When output looks wrong, check the byte sequence before checking the tool.
Verify it yourself
Encoders are pure functions over bytes. Decode the output again and you should get the input back exactly.
- 1.Open DevTools on this page and switch to the Network tab
- 2.Keep the filter on Fetch/XHR and run the tool
- 3.Confirm no request carries your file — you should see only page assets and fonts
Frequently asked questions
What is Base64 encoding?
It is a way to represent data using 64 characters, useful when binary data must be handled as text.
Is my data uploaded?
No. Everything runs in your browser and nothing is sent to a server.
Does it support Unicode?
Yes. Text is encoded as UTF-8 correctly.
What this kind of conversion cannot keep
Encoding and hashing run through the browser's Web Crypto API or a pure-JavaScript implementation. The output is deterministic: the same input always produces the same digest, so you can verify a result against any other tool.
More in Encoding
On this page
- What is Base64 Encode
- What this tool actually does with your file
- How it actually behaves
- How to use it
- How it works inside
- Frequently asked questions
Excel formula reference
29 functions with syntax, arguments and a table you can retype.
Browse the list →