Base64 Encode & Decode
Base64 Encode & Decode is a free, instant online tool for converting text and binary data to and from Base64 format. Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters, making it safe to transmit over text-based protocols like email (MIME), JSON, XML, and URLs. This tool handles both encoding (converting your data to Base64) and decoding (converting Base64 back to original text or binary). It supports UTF-8 text, handles large inputs efficiently, and works entirely in your browser with no data sent to any server. Perfect for developers working with API authentication headers, data URIs, JWT tokens, or any scenario requiring Base64 conversion.
What Is
Base64 is an encoding scheme that converts binary data into a text string using a set of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). The equals sign (=) is used as padding at the end to ensure the output length is a multiple of 4. Why Base64 exists: Many systems and protocols were designed to handle only text data. When you need to send binary data (images, files, encrypted content) through these text-only channels, Base64 provides a safe representation that won't be corrupted by character encoding issues, special characters, or transport mechanisms. Common use cases: - Email attachments (MIME): Binary files are Base64-encoded for email transmission - Data URIs: Embed images directly in HTML/CSS using data:image/png;base64,... - HTTP Basic Authentication: Credentials are encoded as Base64 in the Authorization header - JSON Web Tokens (JWT): The header and payload sections are Base64-encoded - API payloads: Binary data in JSON APIs is often Base64-encoded - URL parameters: Binary data can be safely passed in URLs using Base64URL variant - Certificate encoding: PEM files use Base64 to encode X.509 certificates How Base64 works: 1. Input data is split into groups of 3 bytes (24 bits) 2. Each 24-bit group is divided into four 6-bit segments 3. Each 6-bit value maps to a character in the Base64 alphabet 4. If input isn't divisible by 3, padding characters (=) are added The encoded output is approximately 33% larger than the original binary data. For text input, the size increase depends on the character encoding used.
How to Use
- Choose your operation mode: select 'Encode' to convert text or binary data to Base64, or 'Decode' to convert a Base64 string back to its original form. The tool automatically detects the mode based on your input in many cases.
- For encoding: paste or type your text into the input area. This can be plain text, JSON, HTML, or any string content. For binary data, use the file upload button to select a file from your device — the tool will read and encode it automatically.
- For decoding: paste a Base64-encoded string into the input area. The tool handles standard Base64 (with + and /) as well as Base64URL (with - and _) variants. It also handles strings with or without padding characters (=).
- Select your encoding options. For text encoding, choose the character encoding of your input (UTF-8 is default and recommended). For decoding, choose whether to output as text (UTF-8) or as a downloadable binary file.
- Click the 'Encode' or 'Decode' button to perform the conversion. The result appears instantly in the output area. For large files, a progress indicator shows the encoding/decoding status.
- Copy the result to your clipboard with the 'Copy' button, or download it as a file. For decoded binary data, the download button saves the original file with its correct MIME type and extension.
Examples
Input: Encode: Hello World
Process: ASCII → Binary → 6-bit groups → Base64 alphabet
Result: SGVsbG8gV29ybGQ=
Input: Decode: SGVsbG8gV29ybGQ=
Process: Base64 alphabet → 6-bit groups → Binary → ASCII
Result: Hello World
Input: Encode: user:pass (Basic Auth)
Process: UTF-8 bytes → Base64
Result: dXNlcjpwYXNz
Related Searches
People also search for: base64 encode, base64 decode, base64 converter, base64 online.
base64 encodebase64 decodebase64 converterbase64 online
Frequently Asked Questions
What is the difference between Base64 and Base64URL?
Base64URL is a variant of Base64 designed for use in URLs and filenames. It replaces the '+' character with '-' and '/' with '_', and typically omits the padding '=' characters. This makes the output safe to include in URL parameters without additional percent-encoding. The tool supports both standard Base64 and Base64URL formats for both encoding and decoding.
Can I encode files and images with this tool?
Yes. Use the file upload button to select any file from your device — images, PDFs, documents, or any binary file. The tool reads the file using the FileReader API and encodes it to Base64. The resulting Base64 string can be used in data URIs, embedded in JSON payloads, or stored in databases. For large files (over 10MB), encoding may take a few seconds depending on your device's performance.
Is Base64 encoding the same as encryption?
No, absolutely not. Base64 is an encoding scheme, not encryption. Anyone can decode Base64 data back to its original form — there is no secret key or password involved. Base64 should never be used to protect sensitive data. If you need to encrypt data, use proper encryption algorithms like AES-256. Base64 is only useful for safely representing binary data in text formats, not for security.
Why does my Base64 string end with one or two equals signs?
The equals signs (=) are padding characters. Base64 encodes data in groups of 3 bytes, producing 4 output characters. If the input length isn't a multiple of 3, padding is added to make the output length a multiple of 4. One remaining byte produces 2 characters + 2 padding signs (==), two remaining bytes produce 3 characters + 1 padding sign (=). The padding is required for correct decoding by most implementations.
How do I handle Base64 in different programming languages?
Most languages have built-in Base64 support. In JavaScript: btoa() for encoding, atob() for decoding (for binary data, use FileReader or Buffer). In Python: base64.b64encode() and base64.b64decode(). In Java: java.util.Base64.getEncoder() and getDecoder(). In C#: Convert.ToBase64String() and Convert.FromBase64String(). In PHP: base64_encode() and base64_decode(). All these handle the standard Base64 alphabet with padding.