User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
0 characters · 0 bytes
Encoding
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

Base64 encoding converts arbitrary binary data into a restricted set of 64 ASCII characters (A - Z, a - z, 0 - 9, +, /) plus = for padding. Every group of 3 input bytes maps to 4 output characters, producing an output size ratio of exactly 43. Encoding a raw Unicode string without first converting it to UTF-8 bytes is the single most common source of corruption in data pipelines, API payloads, and email attachments. This tool performs proper UTF-8 byte serialization before applying the Base64 alphabet, so multi-byte characters (emoji, CJK, Cyrillic) encode correctly.

Two encoding variants are supported. Standard Base64 follows RFC 4648 ยง4 and is used in MIME email and PEM certificates. URL-safe Base64 follows RFC 4648 ยง5, replacing + with - and / with _, and stripping = padding, which prevents breakage in query strings and filenames. Choosing the wrong variant will cause parse failures downstream. This tool approximates output size instantly and lets you toggle MIME line wrapping at 76 characters per RFC 2045.

base64 encode string encoder base64 converter text to base64 utf-8 base64 url-safe base64

Formulas

Base64 processes input as a stream of bytes. Each group of 3 bytes (24 bits) is split into 4 sextets (6 bits each). Each sextet indexes the Base64 alphabet table above.

nout = 4 โ‹… ceil(nbytes3)

Where nout = number of output Base64 characters (including padding), and nbytes = byte length of the UTF-8 encoded input. The overhead ratio converges to 43 1.333 for large inputs.

Bit extraction for sextet k from a 24-bit group G:

indexk = (G >> (18 โˆ’ 6k)) โˆง 0x3F

Where k โˆˆ {0, 1, 2, 3} and 0x3F = 63 masks the lower 6 bits.

For URL-safe encoding (RFC 4648 ยง5), two substitutions are applied to the output alphabet:

+ โ†’ - , / โ†’ _ , = padding removed

Reference Data

CharacterIndexCharacterIndexCharacterIndexCharacterIndex
A0Q16g32w48
B1R17h33x49
C2S18i34y50
D3T19j35z51
E4U20k36052
F5V21l37153
G6W22m38254
H7X23n39355
I8Y24o40456
J9Z25p41557
K10a26q42658
L11b27r43759
M12c28s44860
N13d29t45961
O14e30u46+62
P15f31v47/63
Padding character: = - appended when input byte length is not divisible by 3

Frequently Asked Questions

The native btoa() function only accepts Latin-1 (ISO 8859-1) characters, where each code point fits in a single byte (range 0 - 255). Characters outside this range (emoji, CJK, Cyrillic, Arabic) have code points above 255 and cause an InvalidCharacterError. The correct approach is to first encode the string to UTF-8 bytes using TextEncoder, then Base64-encode those bytes. This tool performs that conversion automatically.
Standard Base64 uses + and /, which are reserved characters in URLs (RFC 3986). If you embed a Base64 value in a query parameter, path segment, or filename, those characters will be percent-encoded or misinterpreted by parsers. URL-safe Base64 (RFC 4648 ยง5) replaces + with - and / with _, and omits = padding. Use it for JWT tokens, URL parameters, cookie values, and any context where the string passes through a URL parser.
RFC 2045 (MIME) mandates that Base64-encoded content in email bodies must not exceed 76 characters per line, with lines terminated by CRLF. This prevents mail transfer agents from truncating or corrupting long lines. If you are generating Base64 for HTTP headers, JSON payloads, or data URIs, do not use line wrapping. Only enable it for MIME email bodies or PEM certificate files.
Base64 output is always exactly 43 the size of the input byte stream, rounded up to the nearest multiple of 4 (due to padding). For a 1000-byte input, the output is 1336 characters. If MIME line wrapping is enabled, additional CRLF sequences add roughly 2.6% overhead.
No. Base64 is an encoding scheme, not encryption. It is trivially reversible by anyone with a decoder. It provides zero confidentiality. Do not use Base64 to hide passwords, API keys, or sensitive data. If you need security, apply actual encryption (AES-256, RSA) before Base64-encoding the ciphertext for transport.
JavaScript strings are limited to approximately 228 characters in V8 (Chrome, Edge) and 230 in SpiderMonkey (Firefox). For inputs exceeding a few hundred megabytes, the browser tab will run out of memory. For typical use cases (configuration files, API payloads, short messages), the encoding completes in under 1 millisecond. The tool displays byte size and character count so you can monitor input scale.