File to Base64
Please select a file to display Base64 result
Usage Instructions
1. Click 'Choose File' to select a file, it will be automatically converted to Base64.
2. Click 'Copy Result' to copy the Base64 to clipboard.
3. Click 'Download Result' to download as a txt file.
4. Click 'Clear' to reset the selection and result.
What is Base64
Base64 is a binary-to-text encoding scheme that represents binary data...
How to Use Base64
- Embed images in HTML
- Transfer binary data in JSON
- Simple data obfuscation
- URL-safe parameters (Base64URL variant)
How to Encode
Base64 Encoding Steps
1. Split the file into 3-byte chunks
2. Convert each chunk into 4 Base64 characters
3. Use '=' padding for incomplete chunks
4. Final encoding includes binary conversion and character mapping
How to Decode
Base64 Decoding Steps
1. Convert each Base64 character to 6-bit binary
2. Combine 4 characters into 3 bytes
3. Remove padding characters
4. Final decoding includes binary conversion and data reconstruction
Base64 in Python
import base64
data = "Hello World".encode('utf-8')
encoded = base64.b64encode(data).decode('utf-8')
print(encoded) # SGVsbG8gV29ybGQ=
Base64 in JavaScript
const data = "Hello World";
const encoded = btoa(data);
console.log(encoded); // SGVsbG8gV29ybGQ=
const buffer = Buffer.from(data).toString('base64');
Base64 in Java
import java.util.Base64;
String data = "Hello World";
String encoded = Base64.getEncoder()
.encodeToString(data.getBytes());
System.out.println(encoded); // SGVsbG8gV29ybGQ=