Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.
Now how to encode and decode strings or any file to Base64 format. Following is a simple tool that can encode and decode Strings, image or any file to Base64 format.
Base64 Encoding
Base64 encoding is used to convert binary data into a text string using a set of 64 different ASCII characters. It's often used to encode data for transmission over media that are designed to deal with text.
Example in Python
To encode a string in Base64:
import base64
# Original string
original_string = "Hello, World!"
# Encode the string
encoded_bytes = base64.b64encode(original_string.encode("utf-8"))
encoded_string = encoded_bytes.decode("utf-8")
print(encoded_string)
Base64 Decoding
Base64 decoding reverses the process of encoding, converting the Base64 encoded string back into its original binary form.
Example in Python:
To decode a Base64 string:
import base64
# Base64 encoded string
encoded_string = "SGVsbG8sIFdvcmxkIQ=="
# Decode the string
decoded_bytes = base64.b64decode(encoded_string)
decoded_string = decoded_bytes.decode("utf-8")
print(decoded_string)
Base64 encoding increases the original data size by approximately 33%. To understand the exact increase and validate storage or transmission limits, check the encoded string size in bytes using our calculator.
❤️ Liked this tool?
If it saved you time, consider buying me a coffee to support future improvements.