We use cookies to understand how DevToolsHub is used and to improve your experience. You can choose which types of cookies to allow.
Encode text to Base64 and decode Base64 to text.
Loading...
Loading...
Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of printable ASCII characters. It is defined in RFC 4648 and uses a 64-character alphabet: the uppercase letters A–Z, lowercase letters a–z, digits 0–9, and the symbols + and /, with = used as padding when the input length is not a multiple of 3 bytes.
Here's how it works: every 3 bytes (24 bits) of input data are divided into four 6-bit groups. Each 6-bit group maps to one of the 64 characters in the Base64 alphabet. This means that 4 characters of Base64 output represent 3 bytes of original data, making Base64-encoded data approximately 33% larger than the original binary. When the input is not a multiple of 3 bytes, the output is padded with = characters to make the output length a multiple of 4.
Base64 is not encryption — it provides no confidentiality or security. Anyone who has the Base64 string can decode it instantly. Its purpose is to ensure that binary data can be safely transmitted over text-based protocols like HTTP, SMTP (email), and JSON, which may interpret certain byte sequences as control characters or modify them during transit. By encoding binary data as Base64, you guarantee that the data remains intact without modification.
A critical distinction is UTF-8 vs ASCII. The original Base64 specification was designed for arbitrary binary data. When encoding text strings, it is essential to first convert the text to UTF-8 bytes before Base64 encoding. This is because characters like emoji (🎉), CJK characters (中文), and accented letters (café) require multiple bytes in UTF-8. Naïvely calling btoa() on such strings without UTF-8 conversion will throw an error in browsers. Our tool correctly handles UTF-8 by using TextEncoder to convert the input string to UTF-8 bytes before encoding, ensuring full Unicode support including emoji, CJK, and all special characters.
Base64 encoding is used everywhere in modern web development: data URIs for embedding images directly in HTML or CSS, HTTP Basic Authentication headers, JWT (JSON Web Token) encoding, email MIME attachments, SAML assertions, and many API protocols. Understanding how Base64 works is essential for any developer working with web APIs, authentication systems, or data serialization.
+ with - and / with _, and removes padding.Base64url is a URL-safe variant of standard Base64, also defined in RFC 4648. Standard Base64 uses the characters + and /, which have special meanings in URLs and file paths. The + character represents a space in URL query strings, and / is a path separator. Additionally, the = padding character can cause issues in some URL contexts.
Base64url solves this by making three substitutions:
+ is replaced with - (hyphen)/ is replaced with _ (underscore)= padding is typically omitted entirelyThis makes Base64url-encoded data safe to use in URLs, filenames, and query parameters without any additional encoding. Base64url is used in JWT tokens, URL-safe API tokens, and many modern web protocols. Our tool supports both standard and URL-safe encoding — just toggle the switch to switch between them.
data:image/png;base64,... URIs, reducing HTTP requests.Authorization: Basic header sends credentials as base64(user:pass).Loading...