Skip to content

Base64 Encode And Decode Online

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 Encode

Convert text or file bytes into Base64.

Optional. Up to 10 MiB (10,485,760 bytes). A selected file takes priority over text. Its raw bytes are encoded locally in your browser without uploading the file.

OR

Text is encoded locally as UTF-8 by default, including emoji and non-Latin scripts. Advanced text encoding offers Latin-1 for legacy byte strings. File encoding always uses raw bytes.

Advanced text encoding

Latin-1 maps U+0000-U+00FF directly to bytes, matching legacy btoa/atob text behavior. This setting affects text encoding and decoded previews only; file bytes and decoded downloads are unchanged.

OpenSSL example

For local files containing raw bytes. These OpenSSL commands use single-line Base64. For text parity, save input.bin as UTF-8 (the default) or Latin-1 to match your selected text encoding.



Base64 Decode

Restore text or a file from Base64.

Choose a Base64 file. It takes priority over text and is decoded locally in your browser.

OR

Decoded text is displayed as UTF-8 by default. Use advanced Latin-1 for legacy text. Invalid UTF-8 has no text preview; Download always preserves the decoded bytes. Standard Base64 accepts ASCII whitespace and omitted padding.

Advanced text encoding

Latin-1 maps U+0000-U+00FF directly to bytes, matching legacy btoa/atob text behavior. This setting affects text encoding and decoded previews only; file bytes and decoded downloads are unchanged.

OpenSSL example

For local files containing raw bytes. These OpenSSL commands use single-line Base64. For text parity, save input.bin as UTF-8 (the default) or Latin-1 to match your selected text encoding.



Text encoding, files, and privacy

UTF-8 is the default for text, supporting accented characters, non-Latin scripts, and emoji. Select Latin-1 under Advanced text encoding for compatibility with older byte-string workflows. Use the same encoding when encoding and decoding text.

Files are encoded as raw bytes, regardless of the text encoding setting. Decoding restores bytes exactly; the encoding setting only controls the text preview. Download binary results even when they cannot be displayed as UTF-8.

All text and file conversions run client-side in your browser. The tool does not send your input or files to a conversion server, avoiding upload delays and unnecessary backend requests. The page still loads normal site resources, analytics, and ads. Base64 is an encoding, not encryption.

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

These Python examples use UTF-8 and match the default text encoding in this workspace, including Unicode. For legacy Latin-1 text, use "latin-1" instead of "utf-8" when converting between text and bytes.

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.

Help Others Find This

References