By Docify

Encode Text to Base64: btoa + UTF-8

• 5 min read

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. Load sample Encode writes SGVsbG8gV29ybGQh for ASCII Hello World!. 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.

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. Load sample fills ASCII Hello World! and does not run Encode. Upload file is a different path — it writes a payload with FileReader.readAsDataURL and does not use this btoa wrapper.

Hello World!

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. Load sample Encode writes SGVsbG8gV29ybGQh. The work stays in the browser.

Step 3: Copy or download the string

Copy writes the output to the clipboard. Download saves it as encoded.txt (text/plain). Load sample Encode of ASCII Hello World! writes:

SGVsbG8gV29ybGQh

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.

username:password → dXNlcm5hbWU6cGFzc3dvcmQ=

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.

<img src="data:image/png;base64,PAYLOAD">

Encode text in the browser

Load sample Encode writes Hello World! SGVsbG8gV29ybGQh. RFC 4648, not base64url. Nothing is uploaded.

Use Base64 Encoder →

FAQ

Does Docify upload the text I encode?
No. Encode, copy, and download run in your browser. The page does not send the text to a server.
How does Docify encode text to Base64?
Encode runs btoa(unescape(encodeURIComponent(input))) so the UTF-8 bytes become RFC 4648 Base64. The alphabet uses +, /, and = padding. It is not base64url (- and _ with no padding). Load sample fills ASCII Hello World! and does not run Encode. Encode writes SGVsbG8gV29ybGQh. Decode of that same string writes Hello World!.
Is Base64 encryption?
No. Anyone can reverse the string with the matching decode path. The page does not hash, encrypt, or protect credentials. Encoding username:password for Basic Auth is just that string in Base64 — the tool has no separate auth mode.
What does Download save after encode?
Download writes the output string as a text/plain blob named encoded.txt. It is not a binary file. File encode is a separate FileReader path — see the file-to-Base64 guide.

Related