Base64 Encoder
Base64 encoding converts binary data (images, files, arbitrary bytes) into ASCII text using 64 printable characters. It is essential for embedding binary data in text-based protocols: HTTP headers, email attachments (MIME), JSON payloads, and data URLs in HTML/CSS. Our tool handles text-to-Base64, file-to-Base64, URL-safe Base64, and data URL generation.
Input Text
Output
What is Base64?
Base64 is a encoding scheme that converts binary data into ASCII text format. It uses 64 safe characters to represent data, making it ideal for transmitting data across text-only channels.
Common uses include:
- Encoding images as data URIs in HTML/CSS
- Encoding credentials in HTTP Basic Auth
- Transferring binary data via email or APIs
- Embedding binary files in JSON or XML
About the Base64 Encoder / Decoder
Base64 encoding converts binary data (images, files, arbitrary bytes) into ASCII text using 64 printable characters. It is essential for embedding binary data in text-based protocols: HTTP headers, email attachments (MIME), JSON payloads, and data URLs in HTML/CSS. Our tool handles text-to-Base64, file-to-Base64, URL-safe Base64, and data URL generation.
How to use it
- Enter text or paste binary data to encode to Base64.
- Paste a Base64 string to decode back to text or binary.
- Upload an image to generate a Base64 data URL (data:image/png;base64,...).
- Toggle between standard Base64 (uses + and /) and URL-safe Base64 (uses - and _).
Formula & methodology
Base64 encodes 3 bytes → 4 characters. Output size = ceil(input bytes / 3) × 4. Padding with = to make output length a multiple of 4. Character set: A–Z, a–z, 0–9, +, / (standard) or -, _ (URL-safe). Encoded size ≈ input size × 4/3 (+33%). btoa() and atob() in JavaScript; base64_encode() in PHP.
Common use cases
- Embedding images directly in HTML/CSS without separate HTTP requests
- JWT tokens: header and payload are Base64url encoded
- API authentication: Basic Auth sends "username:password" as Base64
- Email: MIME encoding for attachments (multipart/mixed)
- Environment variables: storing binary secrets as Base64 in .env files
Frequently asked questions
Related tools
All Tools →Embed this tool on your site
Free for personal and commercial use. Just copy the snippet below.