Base64 Encoder & Decoder
Encode and decode Base64 instantly. Supports file-to-data-URI conversion.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) to represent data, making it safe for text-based systems like email, JSON, and URLs.
When to Use Base64
Base64 is commonly used to embed images in HTML or CSS (data URIs), transmit binary data in JSON APIs, encode email attachments (MIME), and store binary data in text-only databases. Note that Base64 increases data size by approximately 33%, so it should not be used for large files.
How This Tool Works
This encoder uses the browser's native btoa() and atob() functions with full UTF-8 support. Your data is processed entirely in your browser — nothing is sent to any server. You can also convert files to Base64 data URIs for embedding in web pages.
Frequently Asked Questions
What is Base64 encoding used for?
Base64 converts binary data into ASCII text, making it safe for text-based systems. Common uses include embedding images in HTML/CSS as data URIs, encoding email attachments (MIME), transmitting binary data in JSON APIs, and storing binary content in text-only databases like XML.
Does Base64 encrypt my data?
No. Base64 is an encoding, not encryption. It transforms data into a different format but does not protect it. Anyone can decode Base64 back to the original data. If you need to protect sensitive data, use proper encryption (AES, RSA) before Base64 encoding.
Why does Base64 increase file size?
Base64 uses 4 ASCII characters to represent every 3 bytes of binary data, resulting in approximately 33% size increase. This trade-off is acceptable for small assets like icons and thumbnails but makes Base64 impractical for large files like videos.
What is a data URI?
A data URI embeds file content directly in HTML or CSS using the format data:[mediatype];base64,[data]. For example, a small PNG image can be embedded as an img src without requiring a separate HTTP request. This tool converts files to data URIs automatically.
When to Use Base64 Encoding
Base64 encoding converts binary data into plain ASCII text using a 64-character alphabet. It is not encryption — anyone can decode it instantly — but it is essential for transmitting binary data through text-only channels.
The most common uses are: embedding images directly in HTML or CSS as data URIs (eliminating a network request for small icons), encoding file attachments in email via MIME, passing binary payloads in JSON API requests, and encoding credentials in HTTP Basic Authentication headers. JWT tokens also use Base64URL — a URL-safe variant — for their header and payload sections.
Base64 adds about 33% size overhead: every 3 bytes of input become 4 Base64 characters. For assets larger than 5KB, the overhead and loss of browser caching usually outweigh the saved HTTP request.
Base64 vs Base64URL
Standard Base64 uses + and / characters which have special meaning in URLs. Base64URL replaces them with - and _, making the output safe for URL parameters and HTTP headers without percent-encoding. JWTs and OAuth tokens use Base64URL. This tool encodes standard Base64; for Base64URL output, replace + with -, / with _, and remove the trailing = padding.
Frequently Asked Questions
Is Base64 encoding the same as encryption?
No. Base64 is reversible with no key — anyone can decode it in one command. It is a format transformation, not a security measure. For real confidentiality, use AES-256 encryption. Read our full guide: Is Base64 Secure? Encoding vs Encryption Explained.
Why does my Base64 string end in == ?
Base64 converts 3 bytes into 4 characters. If the input length is not divisible by 3, padding is added. One leftover byte produces ==, two leftover bytes produce =. The decoder uses the padding to know how many bytes were in the final group.
Can I encode image files?
Yes — drag a file onto the tool or click the file input. The tool reads your file in the browser using the FileReader API, encodes it to Base64, and generates a ready-to-paste data:image/png;base64,... data URI. Your file is never uploaded to any server.
What is the maximum file size supported?
The tool processes files up to approximately 5MB comfortably in most browsers. Larger files may slow down due to browser memory constraints. For very large files, use a command-line tool: base64 -i input.bin -o output.txt on macOS/Linux.