Base64 Encoder / Decoder
Encode text to Base64 and decode Base64 strings back to plain text instantly with real-time conversion
0
0
Encode
Idle
Input
Enter plain text to encode to Base64
0 chars
Quick Examples
Try these sample inputs to see Base64 encoding in action
Output
Enter text and select a mode to see the result here
Copy Output
Enter text and select a mode to generate output
No output generated yet
Status Checklist
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters: the uppercase letters A through Z, the lowercase letters a through z, the digits 0 through 9, the plus sign (+), and the forward slash (/). The equals sign (=) is used as padding at the end of the encoded string when the input length is not a multiple of 3 bytes.
The encoding works by dividing the input binary data into groups of 3 bytes (24 bits), then splitting each group into 4 sets of 6 bits. Each 6-bit value is mapped to one of the 64 characters in the Base64 alphabet. This means every 3 bytes of input produce exactly 4 characters of output, resulting in an approximate 33% size increase. The reverse process — decoding — converts the 4-character groups back into their original 3-byte binary representations.
This Base64 encoder/decoder tool handles the full UTF-8 spectrum, meaning it correctly encodes and decodes Unicode characters, emojis, and multi-byte sequences. The input text is first converted to UTF-8 bytes before Base64 encoding, and decoded Base64 bytes are interpreted as UTF-8 when converting back to text. This ensures that characters beyond the basic ASCII range — such as accented letters, Cyrillic, Chinese, Japanese, and emoji — are preserved accurately through the encoding and decoding cycle.
How Does Base64 Encoding Work?
The Base64 encoding process follows a precise algorithm that converts binary data into a text-safe representation:
- UTF-8 Conversion: The input text string is first converted to a sequence of bytes using UTF-8 encoding. For example, the character "A" becomes the byte 0x41, while "é" becomes two bytes (0xC3, 0xA9), and an emoji like "😀" becomes four bytes (0xF0, 0x9F, 0x98, 0x80).
- Byte Grouping: The byte sequence is divided into groups of 3 bytes (24 bits each). If the total number of bytes is not a multiple of 3, the final group has 1 or 2 bytes with zero-padding added to complete the 24-bit block.
- 6-Bit Splitting: Each 24-bit group is split into four 6-bit chunks. For example, the bytes "Man" (0x4D, 0x61, 0x6E) become the 6-bit values 19, 22, 5, 46.
- Character Mapping: Each 6-bit value is mapped to a character in the Base64 alphabet (A-Z = 0-25, a-z = 26-51, 0-9 = 52-61, + = 62, / = 63). Continuing the example, 19=T, 22=W, 5=F, 46=u, producing "TWFu".
- Padding: If the input had only 1 byte remaining, two padding characters (==) are added. If 2 bytes remained, one padding character (=) is added. This signals to the decoder how many bytes to expect in the final group.
- Decoding Reverses the Process: The decoder maps each Base64 character back to its 6-bit value, combines groups of four 6-bit values into 24 bits, then splits them into 3 bytes, and finally interprets the bytes as UTF-8 text.
This tool implements the standard Base64 encoding defined in RFC 4648. The encoding and decoding are performed entirely in your browser using the built-in btoa() and atob() functions with proper UTF-8 handling via the TextEncoder and TextDecoder APIs.
Common Uses of Base64 Encoding
Data URIs in HTML/CSS
Small images can be embedded directly in HTML or CSS using Base64 data URIs (e.g., data:image/png;base64,...), eliminating extra HTTP requests.
Email Attachments (MIME)
Email protocols like SMTP only support 7-bit ASCII. Base64 encoding converts binary attachments into ASCII-safe text for reliable email delivery.
Basic Authentication
HTTP Basic Authentication encodes the username:password pair as Base64 in the Authorization header (e.g., Basic dXNlcjpwYXNz).
JSON Web Tokens (JWT)
JWT tokens use Base64URL encoding (a variant of Base64) for their header and payload segments, encoding structured data as URL-safe strings.
Binary Data in JSON APIs
JSON cannot natively represent binary data. Base64 encoding allows binary files, hashes, and encrypted data to be safely included in JSON payloads.
Hash and Signature Encoding
Cryptographic hashes (MD5, SHA-256) and digital signatures produce raw binary output that is commonly represented as Base64 strings for storage and transmission.
How to Use This Base64 Tool
- Select the Mode: Choose "Encode" to convert plain text to Base64, or "Decode" to convert a Base64 string back to plain text. The mode toggle is at the top of the input panel.
- Enter Your Text: Type or paste your text into the input textarea. In encode mode, enter any plain text including Unicode characters and emojis. In decode mode, paste a Base64-encoded string.
- Real-Time Conversion: The output updates instantly as you type — there is no need to click a convert button. The conversion happens character by character in real time.
- Review the Output: Check the result panel to see the converted output. Switch between "Result" view (styled preview) and "Raw" view (plain text) using the tabs.
- Check Validation: The status checklist monitors your input and output in real time. In decode mode, it validates that the input is proper Base64 format and flags any decoding errors.
- Copy the Output: Click the "Copy" button to copy the output to your clipboard. You can also copy from the raw view using the inline copy button.
- Try Examples: Click the quick example buttons to load sample inputs — "Hello World" for simple text, "JSON String" for structured data, "Emoji Text" for Unicode testing, and "Special Chars" for characters that require multi-byte encoding.
- Clear and Start Over: Click "Clear All" to reset both the input and output fields and return to the default state.
Practical Use Cases
- Embedding Images in HTML/CSS: Convert small icons, logos, or placeholder images to Base64 data URIs and embed them directly in your stylesheets or HTML. This eliminates extra HTTP requests and works offline, but should only be used for small images (under 10KB) to avoid bloating your page size.
- Testing API Authentication: When working with APIs that use Basic Authentication, encode your credentials as Base64 to construct the Authorization header. This tool lets you quickly generate the encoded string for testing in Postman, curl, or your application code.
- Inspecting JWT Tokens: Decode JWT tokens by splitting them on the dots and decoding each part as Base64. The header and payload segments reveal the token's metadata, claims, and expiration time without needing a specialized JWT debugger.
- Data Migration and ETL: When migrating data between systems that handle binary fields differently, Base64 encoding provides a universal intermediate format. Encode binary data before export and decode it after import to ensure data integrity across different database and file systems.
- Debugging Email Issues: When email attachments arrive corrupted or don't display correctly, decoding the raw Base64 content from the email source reveals the actual binary data and helps identify encoding problems in the mail transfer process.
- Creating Test Data: Generate Base64-encoded test strings for unit tests, mock API responses, or fixture data. This tool makes it easy to create predictable, reproducible encoded strings for your test suites.
- Working with Configuration Files: Some configuration systems (like Kubernetes Secrets, Docker configs, or CI/CD pipelines) store values as Base64. Use this tool to encode sensitive values before adding them to configuration, or decode existing values to verify their contents.
Frequently Asked Questions
Explore More Tools
Once you have encoded or decoded your Base64 strings, try these related tools: