Base64 Encode
Encode text, files, and images to Base64 instantly in your browser. Convert any data to Base64 format with our free, privacy-first encoder tool.
Drop a file here or click to browse
Images, documents, any file type
How to Use the Base64 Encoder
- 1 Enter your text - Type or paste the text you want to encode in the input field, or upload a file.
- 2 Choose encoding options - Enable URL-Safe mode if you need the output for URLs (replaces + and / with - and _).
- 3 Click "Encode to Base64" - The encoded result appears instantly in the output field.
- 4 Copy and use - Click the Copy button to copy the Base64 string to your clipboard.
Common Use Cases
Data URIs for Images
Embed images directly in HTML or CSS using data URIs, reducing HTTP requests.
API Data Transmission
Send binary data through JSON APIs that only support text-based content.
Email Attachments
Encode files for MIME email attachments and inline content embedding.
Database Storage
Store binary data in text-only database fields or configuration files.
Base64 Encode Examples
Example 1: Simple Text
Hello World!
SGVsbG8gV29ybGQh
Example 2: JSON Object
{"name":"John","age":30}
eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9
Example 3: URL-Safe Encoding
<<??>>
PDw_Pz4-
Example 4: Data URI for Image
<img src="data:image/png;base64,iVBORw0KGgo..." />
Frequently Asked Questions
What is Base64 encoding?
Base64 encoding converts binary data into a text format using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). This allows binary data to be safely transmitted over text-based protocols or stored in text-only formats.
Does Base64 encoding increase file size?
Yes, Base64 encoding increases data size by approximately 33%. For every 3 bytes of input, you get 4 bytes of Base64 output. This is the trade-off for being able to represent binary data as safe ASCII text.
Is Base64 encoding secure?
Base64 is NOT encryption. It's simply an encoding scheme that can be easily reversed by anyone. Never use Base64 alone to protect sensitive data. If you need security, use proper encryption methods (like AES) before Base64 encoding.
When should I use URL-safe Base64?
Use URL-safe Base64 when the encoded string will be used in URLs, query parameters, or filenames. Standard Base64 uses + and / which have special meanings in URLs and would require additional percent-encoding.
Can I encode images to Base64?
Yes! Simply drop your image file into the upload area. The encoder will convert it to Base64, which you can then use in data URIs for embedding images directly in HTML or CSS without separate image files.
Related Tools
Technical Details
Base64 encoding works by taking groups of 3 bytes (24 bits) and splitting them into 4 groups of 6 bits each. Each 6-bit group maps to one of 64 characters:
- Character set: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63)
- URL-safe variant: Uses - (62) and _ (63) instead of + and /
- Padding: = characters are added to make output length a multiple of 4
- Size increase: Output is 4/3 (≈133%) the size of input
This encoder uses the native JavaScript btoa() function with
encodeURIComponent() for proper Unicode handling, ensuring all characters
encode correctly.