Instant Encoding · 4 Charsets · Decode Included

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.

UTF-8 UTF-16LE UTF-16BE Latin-1 ASCII Unicode Emoji ✓
Character encoding:
Input Text 0 chars · 0 bytes
Base64 Output 0 chars
Base64 output will appear here as you type…
4
Character Encodings
4
Code Snippets
0ms
Server Latency
100%
Private & Secure

Encode Text to Base64 in Three Steps

No sign-up, no server uploads. Type, encode, and copy in seconds.

1

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.

2

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.

3

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.

EncodingBytes per charUnicode supportEmoji supportBest for
UTF-81–4 bytes (variable)FullYesWeb APIs, JSON payloads, general-purpose encoding the universal default
🔁UTF-16 LE2 or 4 bytesFullYesWindows file systems, .NET strings, Java internal strings (little-endian)
🔁UTF-16 BE2 or 4 bytesFullYesNetwork protocols, Java I/O streams, big-endian system interop
🌐Latin-1 / ISO-8859-11 byte exactlyWestern onlyNoLegacy 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.

01

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.

02

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.

03

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.

04

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.

05

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.

06

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.

// Text → Base64 (UTF-8, full Unicode)
 
function toBase64(str) {
  const bytes = new TextEncoder()
    .encode(str);
  const bin = String.fromCharCode
    (...bytes);
  return btoa(bin);
}
 
// Base64 → Text (decode)
function fromBase64(b64) {
  const bin = atob(b64);
  const bytes = Uint8Array
    .from(bin, c => c.charCodeAt(0));
  return new TextDecoder()
    .decode(bytes);
}

Frequently Asked Questions

Everything you need to know about encoding text strings to Base64.

Base64 is an encoding scheme that converts binary data (bytes) into a string of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is used for text when you need to safely transport or store a string in a context that only accepts ASCII characters such as HTTP headers, JSON fields, XML attributes, email MIME parts, and URL query parameters. Base64 ensures the data survives transport without being corrupted by systems that misinterpret non-ASCII bytes.
UTF-8 is the correct choice for nearly all modern use cases. It is the encoding used by default in HTML5, JSON, HTTP/1.1+, and virtually all modern web APIs. Choose UTF-16 LE if you are working with Windows file system strings, .NET applications, or Java internal string representations. Choose Latin-1 only for legacy systems, HTTP header values, or MIME email headers that explicitly require ISO-8859-1. Using the wrong charset will produce a different Base64 output and incorrect decoding at the receiving end.
JavaScript's built-in 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.
No. Base64 is an encoding scheme, not an encryption algorithm. It is fully reversible by anyone using a standard decoder no key or password is required. It should never be used to hide sensitive information such as passwords, API keys, or personal data. For security, use proper encryption (AES, RSA) or hashing (bcrypt, SHA-256). Base64 is used solely to make binary data safe for text-based transport, not to protect it from being read.
Standard Base64 uses + 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.
Use the Decode tab on this page paste your Base64 string, select the charset that was used during encoding (UTF-8 for most cases), and the decoded text appears instantly. In JavaScript: 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').
No. All encoding and decoding on this page uses native browser APIs 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.
Use the 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.