What is Base64 encoding?
Base64 is an encoding scheme that converts binary data into a text-based format using a set of 64 safe characters (letters, numbers, +, /, and =). The purpose of Base64 is to represent binary data in a way that can be safely transmitted through systems that only support text (like emails, JSON APIs, and HTML). When you encode data with Base64, you are converting raw bytes into a string of printable characters that any system can handle.
Base64 does not encrypt data—it is purely a encoding format. Anyone with a Base64-encoded string can easily decode it back to the original data. Therefore, Base64 should never be used for security purposes. It is useful for transmitting images in JSON, embedding fonts in CSS, storing binary files as text, and protecting against certain parsing issues in data transmission.
The name "Base64" comes from the fact that it uses 64 characters in its alphabet. Each encoded character represents 6 bits of data, which is why encoding typically increases data size by about 33% compared to the original binary form.
When should you use the Base64 Encoder/Decoder?
Encode images to embed in JSON: When building APIs or web applications that need to send images as JSON, you can Base64-encode the image file and include it in the response. The client can then decode it and display it in the browser.
Email attachments and headers: Email systems traditionally use Base64 to encode attachments and binary data in email headers. When you send an attachment through SMTP, it is Base64-encoded to ensure it survives transmission across email servers.
Data URLs in HTML and CSS: Use Base64 encoding to create data URLs that embed images, fonts, and other resources directly into HTML and CSS files. This reduces HTTP requests and improves page load performance for small resources.
API authentication credentials: Some APIs require you to send username and password credentials in the Authorization header using Basic Authentication, which Base64-encodes "username:password". This tool helps you generate that encoded string quickly.
Storing binary data in text databases: If you need to store binary files (like PDFs or images) in a text-based database without BLOB support, Base64 encoding allows you to represent the data as text.
JWT tokens and cookie values: JWTs and secure cookies often use Base64 encoding for their payloads. Understanding how to encode and decode these formats helps with debugging and token inspection.
How to use the Base64 Encoder/Decoder
Step 1: Paste your text or data into the input field on the left side. You can paste plain text, JSON, HTML, or any data you want to encode.
Step 2: The tool will automatically detect whether you want to encode or decode. If it recognizes the input as valid Base64 (only contains Base64 characters), it will default to decoding. Otherwise, it will encode.
Step 3: For encoding, the tool converts your input into Base64 format. Each character in the input becomes a series of Base64 characters. The output will be longer than the input, usually by about 33%.
Step 4: For decoding, the tool converts Base64 back into the original text. If the Base64 is valid, you will see the original data. If it is corrupted or incomplete, the decoder will report an error.
Step 5: Copy the result using the copy button. You can then use the encoded string in your API response, HTML, CSS, email, or wherever you need to transmit text-safe binary data.
Step 6: Test by decoding what you just encoded. Paste the Base64 output back into the tool and set it to decode mode to verify the data is unchanged.
Common errors and how to fix them
Error: Invalid Base64 format when decoding. If you are trying to decode data and see an error, ensure the input contains only valid Base64 characters (A-Z, a-z, 0-9, +, /, and =). If there are extra line breaks, spaces, or other characters, remove them.
Error: Incomplete Base64 string. Base64-encoded strings must be a multiple of 4 characters (padded with = signs if needed). If your string is missing padding or is cut off, add the required = characters at the end.
Error: Special characters causing encoding issues. If you are encoding text with special characters (accents, emojis, non-ASCII characters), ensure you are working with the correct character encoding (usually UTF-8). The tool should handle this automatically.
Error: Line breaks in the middle of Base64. When copying Base64 from emails or documents, line breaks are sometimes added for readability. Remove all line breaks and extra spaces before decoding.
Error: Case sensitivity matters. Base64 is case-sensitive, so "Ab" is different from "ab". When copying, ensure you preserve the exact capitalization.
Related tools
URL Encoder/Decoder: For encoding URLs and query parameters, use the URL Encoder. It handles percent-encoding, which is different from Base64 but serves a similar purpose for URLs.
Hash Generator: If you need to generate cryptographic hashes (like SHA-256) instead of Base64 encoding, use the Hash Generator.
JWT Decoder: JWTs are partially Base64-encoded. Use the JWT Decoder to inspect and parse JWT tokens.