Text to Base64 Encoder
Type or paste any text and get a Base64 string instantly as you type. Supports UTF-8, UTF-16, Latin-1, and ASCII. Includes a Base64 decoder tab. Nothing ever leaves your browser.
Encode Text to Base64 in Three Steps
No sign-up, no server uploads. Type, encode, and copy in seconds.
Type or Paste Your Text
Enter any text in the input box plain English, multi-line content, JSON, HTML, code, Unicode characters, or emoji. Select a character encoding (UTF-8 is recommended for the vast majority of use cases). The encoding begins immediately as you type.
Instant Base64 Encoding
The browser converts your text to bytes using the selected charset via the native TextEncoder API, then encodes those bytes to Base64. The output is updated in real time with every keystroke no button press needed. Character, byte, and Base64 length counters update live.
Copy, Download, or Use a Snippet
Copy the raw Base64 string, download it as a .txt file, or switch to the Snippets tab for ready-to-paste btoa(), Python base64.b64encode(), Node.js Buffer, and curl code blocks all pre-filled with your encoded text.
Everything You Need to Encode Text
A complete text encoding toolkit with multi-charset support, live counters, decode tab, and developer snippet generation.
Instant Live Encoding
Base64 output updates with every keystroke via the browser's native TextEncoder API no button press, no delay. Character count, byte count, and Base64 output length are all updated in real time.
4 Character Encodings
Choose between UTF-8 (the web standard), UTF-16 LE, UTF-16 BE, and Latin-1 / ISO-8859-1. Switching charset instantly re-encodes your text, letting you compare outputs for the same input string.
Built-in Base64 Decoder
The Decode tab lets you paste any Base64 string and instantly decode it back to readable text. Select the charset that was used for encoding to get the correct output. Invalid Base64 inputs are flagged with a clear error message.
4 Developer Code Snippets
One-click copy for: JavaScript btoa() / TextEncoder, Python base64.b64encode(), Node.js Buffer.from(), and a curl command all pre-filled with your encoded text.
One-Click Copy
Copy the raw Base64 string to your clipboard in one click. The live character and byte counters help you stay within API payload limits or storage constraints before you copy.
100% Private
All encoding and decoding uses native browser APIs (TextEncoder, atob, btoa). Your text never leaves your device. Safe for passwords, tokens, private messages, and confidential data.
Supported Charsets & When to Use Each
The character encoding you choose determines how text bytes are produced before Base64 encoding. Here is a reference for each supported charset.
| Encoding | Bytes per char | Unicode support | Emoji support | Best for | |
|---|---|---|---|---|---|
| ✅ | UTF-8 | 1–4 bytes (variable) | Full | Yes | Web APIs, JSON payloads, general-purpose encoding the universal default |
| 🔁 | UTF-16 LE | 2 or 4 bytes | Full | Yes | Windows file systems, .NET strings, Java internal strings (little-endian) |
| 🔁 | UTF-16 BE | 2 or 4 bytes | Full | Yes | Network protocols, Java I/O streams, big-endian system interop |
| 🌐 | Latin-1 / ISO-8859-1 | 1 byte exactly | Western only | No | Legacy systems, HTTP headers, MIME email headers, older Western European text |
When You Need Text as Base64
Base64-encoding text solves real problems across authentication, APIs, email, storage, and data transport.
HTTP Basic Authentication Headers
HTTP Basic Auth requires credentials in the format Authorization: Basic [base64(username:password)]. Encode your username:password string here to generate the correct header value for API testing in Postman, curl, or direct HTTP calls. The output is ready to paste after the Basic prefix.
JWT & Token Payload Inspection
JSON Web Tokens (JWTs) consist of Base64url-encoded header, payload, and signature segments. Use the decode tab to paste any JWT segment and decode it back to JSON for inspection during development and debugging. Note that JWT uses Base64url (URL-safe) encoding replace - with + and _ with / before decoding.
Encoding JSON for API Payloads
Some APIs require JSON strings, configuration objects, or webhook payloads to be transmitted as Base64-encoded strings inside a parent JSON body to avoid escaping conflicts, enforce opaque payloads, or meet API schema requirements. Encode your JSON string here and paste it directly into the API payload field.
Email MIME Encoding
MIME email headers and body parts that contain non-ASCII characters must be encoded using Quoted-Printable or Base64 encoding (per RFC 2045). Base64 is preferred for content with a high proportion of non-ASCII characters such as CJK text, Arabic, or Hebrew. Encode your email body or header value here and wrap it in the appropriate MIME content-transfer-encoding declaration.
Storing Strings in Binary-Safe Systems
Some systems message queues (Kafka, SQS), binary protocol buffers, certain databases, and configuration stores are designed for binary or ASCII data and may corrupt arbitrary UTF-8 strings. Base64 encoding any text string before storage ensures it is composed entirely of safe ASCII characters and can be round-tripped without corruption.
Obfuscating Strings in Source Code
While Base64 is not encryption and should not be used as a security measure, developers sometimes encode strings (URLs, configuration values, internal identifiers) in source code or config files as Base64 to prevent accidental exposure in logs, console output, and code reviews. Encode the string here and use atob() to decode it at runtime.
Text to Base64 Encoding Explained
Encoding text to Base64 is a two-step process: first the text string is converted to bytes using a character encoding (such as UTF-8), then those bytes are encoded to Base64. The character encoding step is critical the same text string produces different Base64 output depending on the charset used, because different charsets represent characters as different byte sequences.
In browsers, the TextEncoder API converts a JavaScript string to a Uint8Array of bytes. The resulting byte array is then converted to a Base64 string. The standard browser btoa() function only handles Latin-1 strings, so for full Unicode support the bytes from TextEncoder must be converted to a binary string before passing to btoa().
To decode, the reverse process is applied: atob() converts the Base64 string back to a binary byte string, the bytes are placed into a Uint8Array, and then TextDecoder converts the bytes back to a JavaScript string using the same charset that was used during encoding. Using the wrong charset during decoding will produce garbled output.
Frequently Asked Questions
Everything you need to know about encoding text strings to Base64.
btoa() function only accepts strings where every character has a code point of 255 or lower (Latin-1 range). Passing a string with characters outside that range such as Chinese, Arabic, emoji, or any accented character beyond Latin-1 throws an InvalidCharacterError. The correct approach is to use TextEncoder to convert the string to UTF-8 bytes first, then encode those bytes with btoa(). The JavaScript snippet in the Snippets tab uses this correct pattern.+ and / as the 62nd and 63rd characters, and uses = as padding. Base64url (used in JWTs, OAuth tokens, and URL-safe contexts) replaces + with - and / with _, and typically omits padding. This makes the output safe for use in URLs and filenames without percent-encoding. To convert standard Base64 to Base64url, replace + → -, / → _, and strip trailing = characters.atob(base64String) for Latin-1, or use TextDecoder with the bytes from atob() for UTF-8. In Python: base64.b64decode(s).decode('utf-8'). In Node.js: Buffer.from(s, 'base64').toString('utf-8').TextEncoder, TextDecoder, btoa(), and atob(). No network requests are made. Your text never leaves your browser. The tool works fully offline after the page loads, making it safe for encoding passwords, private keys, API tokens, confidential messages, and sensitive configuration values.base64 standard library: import base64; base64.b64encode("your text".encode("utf-8")).decode("utf-8"). The .encode("utf-8") step converts the string to bytes, base64.b64encode() encodes those bytes to Base64, and .decode("utf-8") converts the resulting bytes back to a string. The Python snippet in the Snippets tab is pre-filled and ready to copy.