Encode Text to Base64: btoa + UTF-8
To encode text to Base64 in the browser, wrap the string as UTF-8 then call btoa. Docify runs btoa(unescape(encodeURIComponent(input))) and uses the RFC 4648 alphabet (+, /, = padding), not base64url. Encoding ASCII Hello World! writes SGVsbG8gV29ybGQh on /base64/. RFC 4648 §10 output foobar is Zm9vYmFy — the same bytes are MZXW6YTBOI====== on /base32/, CPNMUOJ1E8====== on /base32hex/, and 666F6F626172 on /base16/. Encode does not call String.prototype.normalize. Encoding NFC é (U+00E9) writes w6k= on /base64/. Encoding NFD e + U+0301 writes ZcyB. Compose e + U+0301 to é (U+00E9) on /unicode-normalize/. Nothing is uploaded.
Base64 turns bytes into ASCII so they can sit in JSON, HTML attributes, or other text fields. It is an encoding, not a lock. The steps below match the live Base64 encoder. RFC 4648 §10 output foobar → Zm9vYmFy is the same alphabet (the sample here is different). Those same bytes are MZXW6YTBOI====== / CPNMUOJ1E8====== / 666F6F626172 on /base32/, /base32hex/, and /base16/.
How to encode text to Base64 in three steps
Step 1: Paste the plain text
Type or paste into the left-hand box on Encode. The Encode button stays disabled until that box has text. The sample fills ASCII Hello World!. Upload file is a different path — it writes a payload with FileReader.readAsDataURL and does not use this btoa wrapper.
Step 2: Click Encode
Open the Docify Base64 tool and click Encode. The page runs btoa(unescape(encodeURIComponent(input))) so non-ASCII characters become UTF-8 before btoa. The example Encode writes SGVsbG8gV29ybGQh. The work stays in the browser.
Step 3: Copy or download the string
Copy copies the text to the clipboard. Download saves it as encoded.txt (text/plain). Encoding ASCII Hello World! writes:
What the encoder actually emits
Alphabet
Output is standard RFC 4648 Base64: letters, digits, +, /, and = padding. It is not base64url. JWT segments and some URL tokens use that other alphabet.
UTF-8 wrap
Bare btoa only accepts Latin-1. The encodeURIComponent / unescape pair first turns the JS string into UTF-8 bytes, so characters outside Latin-1 encode instead of throwing.
Not a data URL
Text encode returns the Base64 payload only. It does not prefix data:…;base64,. If you need that prefix for an <img> or CSS url, add the MIME type yourself. File encode also strips the prefix — see Convert a file to Base64 (FileReader).
Common uses this page does not automate
HTTP Basic Auth
You can paste username:password and encode it. The tool does not build an Authorization header and does not treat the result as a secret.
Images in HTML
A data URL needs a MIME prefix plus the payload. Encoding a filename as text is not the same as encoding the file bytes. Use Upload file on Encode for the bytes, then add the prefix.
RFC 4648 output family
Hello World! is the sample; foobar is §10
The sample on /base64/ fills ASCII Hello World! and writes SGVsbG8gV29ybGQh. That is not the RFC 4648 §10 vector. Encoding foobar on the same page writes Zm9vYmFy — the same string as /base64url/ because that vector has no + or /. The same UTF-8 bytes are MZXW6YTBOI====== on /base32/, CPNMUOJ1E8====== on /base32hex/, and 666F6F626172 on /base16/.
UTF-8 Base64 is not NFC
Base64 of NFC é is w6k=; NFD e + U+0301 produces ZcyB
Text encode wraps the typed string as UTF-8 with encodeURIComponent / unescape before btoa. It does not call String.prototype.normalize. Canonically equivalent é (U+00E9, UTF-8 C3 A9) and é (e + U+0301, UTF-8 65 CC 81) therefore produce different RFC 4648 strings.
Try it with ASCII Hello World!. UAX #15 output e + U+0301 → é (U+00E9) as normalized.txt is /unicode-normalize/. FileReader encodes file bytes as-is, not this output.
Encode text in the browser
Encode gives Hello World! → SGVsbG8gV29ybGQh. RFC 4648, not base64url. Nothing is uploaded.
FAQ
- How do I encode text to Base64?
- Paste your text and click Encode. The tool converts UTF-8 text to standard RFC 4648 Base64 using btoa().
- Does this tool upload my data?
- No. All encoding runs in your browser using JavaScript. Your text is never sent to a server.
- Can I encode files to Base64?
- Yes, use the file upload option. The tool reads the file with FileReader and outputs the Base64 payload.
- What characters does Base64 use?
- Standard Base64 uses A-Z, a-z, 0-9, +, and /, with = for padding. Base64URL uses - and _ instead of + and /.
- Does encoding handle Unicode correctly?
- Yes. Text is converted to UTF-8 bytes before encoding, so accented characters and emoji work correctly.
Related
- Base64 vs Base64URL: URL-Safe Alphabet
- Compact JWS vs JWE: Decode Is Not Verify
- Decode Base64 to UTF-8: atob
- Convert a File to Base64: FileReader
- Hex vs Base64 vs Base32: RFC 4648 Encodings
- RFC 4648 Base32 vs Base32hex: Alphabet and Sort Order
- Live tool: Base64 encoder / decoder · Base32 encoder · Base32hex encoder · Base16 encoder · Unicode NFC / NFD