What is Base64 Encoding?
Base64 is a method of encoding binary data into ASCII characters, making it safe for transmission over text-based protocols like email or URLs. It's commonly used for embedding image data, transmitting files, or storing data in JSON or XML. This tool lets you encode and decode Base64 text instantly, directly in your browser. Quickly encode or decode your text using Base64.
Base64 Encoder / Decoder
Need to safely encode or decode URLs? Try our URL Encoder/Decoder tool for quick and easy web-safe conversions.
Go to URL Encoder/DecoderWhere Is Base64 Encoding and Decoding Used?
Base64 encoding is a method that transforms binary data into a text format that can be safely transmitted over channels supporting only text, such as email systems, JSON data, or URLs. It is commonly used to embed images or files directly into HTML, CSS, or XML without needing separate file requests, which improves load performance and simplifies deployment. Additionally, Base64 encoding allows secure storage of complex data like certificates, encryption keys, or multimedia in databases or config files without corruption. The decoding process reverses this, allowing the original data to be retrieved. This tool is vital for developers and IT professionals who want to ensure data is encoded and decoded correctly, ensuring compatibility and integrity between systems and applications.
Base64 Encode & Decode Examples
Below you can find examples in the three most commonly used programming languages for Base64 formatting: C#, JavaScript, and Python. You can easily copy and use them in your own projects.
Base64 Encode and Decode in C#
// Base64 Encode
string original = "Hello World!";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(original);
string encoded = System.Convert.ToBase64String(bytes);
Console.WriteLine("Encoded: " + encoded);
// Base64 Decode
string encodedString = encoded;
byte[] decodedBytes = System.Convert.FromBase64String(encodedString);
string decoded = System.Text.Encoding.UTF8.GetString(decodedBytes);
Console.WriteLine("Decoded: " + decoded);
Base64 Encode and Decode in JavaScript
// Base64 Encode
const text = "Hello World!";
const encoded = btoa(text);
console.log("Encoded:", encoded);
// Base64 Decode
const decoded = atob(encoded);
console.log("Decoded:", decoded);
Base64 Encode and Decode in Python
import base64
# Base64 Encode
original = "Hello World!"
encoded_bytes = base64.b64encode(original.encode("utf-8"))
encoded_str = encoded_bytes.decode("utf-8")
print("Encoded:", encoded_str)
# Base64 Decode
decoded_bytes = base64.b64decode(encoded_str)
decoded_str = decoded_bytes.decode("utf-8")
print("Decoded:", decoded_str)