Encode any plain text, JSON payload, API secret, or Unicode string into clean, standards-compliant Base64 instantly with our free online Base64 encoder. Base64 is one of the most widely implemented binary-to-text conversion formats in computer science, allowing 8-bit binary and multi-byte text data to travel securely across network channels and protocols originally architected for plain 7-bit ASCII text.
Whether you are crafting HTTP Basic Authentication credentials, packaging data into JSON and XML envelopes, preparing inline data URIs for web assets, or developing cloud microservices, this encoder delivers complete precision. It natively supports both Standard Base64 (RFC 4648 §4) and URL-Safe Base64 (RFC 4648 §5), configurable padding, optional MIME line wrapping, and real-time character expansion metrics. For the reverse conversion, visit our Base64 Decoder or explore our URL Encoder and JWT Decoder.
100% Private & Client-Side: Security and data privacy are paramount when dealing with API tokens, passwords, and sensitive strings. All Base64 conversions take place entirely inside your web browser runtime using native client-side JavaScript APIs. Your input text is never uploaded to any remote server, never logged in databases, and never transmitted over the internet.
Below is an example showing how plain human-readable text containing punctuation, query symbols, and special characters is translated into Standard vs. URL-Safe Base64:
Input Plain Text (API token with query characters):
API-Key: test?sec>token?data=hello/world+uploadOutput - Standard Base64 (RFC 4648 with + and /):
QVBJLUtleTogdGVzdD9zZWM+dG9rZW4/ZGF0YT1oZWxsby93b3JsZCt1cGxvYWQ=Output - URL-Safe Base64 (RFC 4648 §5, replacing + with - and / with _):
QVBJLUtleTogdGVzdD9zZWM-dG9rZW4_ZGF0YT1oZWxsby_3b3JsZCt1cGxvYWQ= Notice how the + character becomes - and the / character becomes _ in URL-Safe mode. Furthermore, international multi-byte Unicode sequences (such as Hello, World! 🚀 → SGVsbG8sIFdvcmxkISDwn5qA) are natively supported via UTF-8 without string corruption.
= padding on or off, and select optional line wrapping (None, 64, or 76 characters). .txt file. + and /) and URL-safe Base64 (using - and _).= padding characters to match API, JWT, or database specification requirements.Authorization: Basic <credentials> header by encoding username:password pairs. data:image/svg+xml;base64,... syntax to eliminate HTTP roundtrips. Base64 is a group of binary-to-text encoding schemes formalized under RFC 4648 (and previously RFC 2045 for MIME). The term Base64 originates from MIME content transfer encoding, reflecting the radix-64 mathematical representation used to represent arbitrary sequences of bytes.
How the Algorithm Works: Computer storage and networks operate fundamentally in 8-bit bytes (octets). Because 64 is equal to 26, any Base64 character can precisely represent 6 bits of binary information. The algorithm groups three consecutive 8-bit bytes (3 × 8 = 24 bits) and segments them into four 6-bit numbers (4 × 6 = 24 bits):
'M', 'a', 'n' = 010011010110000101101110)010011 (19), 010110 (22), 000101 (5), 101110 (46)'T', index 22 = 'W', index 5 = 'F', index 46 = 'u'. The result is "TWFu".The 64-Character Alphabet: The standard alphabet consists of uppercase letters A–Z (indices 0–25), lowercase letters a–z (indices 26–51), numerals 0–9 (indices 52–61), plus symbol + (index 62), and slash / (index 63).
Padding Rules: If the length of the input data is not an exact multiple of 3 bytes, padding is required. When 1 byte remains (8 bits), it is padded with four zero bits to form two 6-bit chunks, followed by two == padding characters. When 2 bytes remain (16 bits), they are padded with two zero bits to form three 6-bit chunks, followed by one = padding character.
Size Expansion: Because 3 bytes are expanded into 4 ASCII characters, Base64 encoding inherently increases data size by approximately 33.3% (or a ratio of 4:3).
btoa() expects binary Latin1 strings where each character code is strictly ≤ 255. Passing multi-byte characters (such as emojis or accented vowels) directly to btoa() throws an InvalidCharacterError. Our tool correctly uses the TextEncoder Web API to serialize strings into UTF-8 byte arrays first. + and /. When placed in URL query parameters, + is frequently interpreted by web servers as a space, and / acts as a path delimiter. Always use URL-safe Base64 (RFC 4648 §5) when embedding Base64 in URLs or HTTP headers. Explore complementary developer and web conversion utilities on BitCompiler: