📁 Encode a File to Base64
Drag & drop a file here, or click to browse
Images, text, PDF — any file up to 2MB
What Is Base64 Encoding & When Do You Need It?
Base64 is a binary-to-text encoding scheme that converts data into a string of 64 printable ASCII characters. It's essential when you need to transmit binary data over channels designed for text, such as email (MIME), JSON APIs, HTTP headers, and HTML attributes.
Common use cases include HTTP Basic Authentication (credentials encoded as Base64 in the Authorization header), embedding images in HTML and CSS as data URIs, JWT tokens, and passing binary payloads in JSON APIs.
Base64 is NOT encryption. It is easily reversible by anyone. Never use Base64 to protect sensitive information like passwords or private keys. Use proper encryption algorithms (AES-256, RSA) for security purposes.
Where Is Base64 Encoding Used?
Base64 is everywhere in modern web development and API design.
HTTP Basic Authentication
API credentials are Base64-encoded as "username:password" and sent in the Authorization header. Our tool lets you instantly encode or decode auth strings.
Embedding Images in HTML/CSS
Images encoded as Base64 data URIs can be embedded directly in HTML img tags or CSS background-image properties — eliminating extra HTTP requests.
JWT Tokens
JSON Web Tokens use URL-safe Base64 to encode their header and payload sections. Decode JWTs to inspect claims without a dedicated JWT tool.
Email Attachments (MIME)
Email protocols encode binary attachments as Base64 to safely transmit files through text-based SMTP servers without data corruption.
API Payloads
REST and GraphQL APIs use Base64 to encode binary data (files, images, certificates) within JSON payloads which can only contain text.
OAuth & Tokens
OAuth 2.0 client credentials, PKCE code verifiers, and many security tokens use URL-safe Base64 encoding for compact, URL-safe representation.
Everything You Need in a Base64 Tool
Developer-grade Base64 encoding with zero friction and full privacy.
Live Mode
Results update in real-time as you type. Toggle Live Mode off for large inputs to process on demand.
URL-Safe Base64
Toggle URL-safe mode to replace + with - and / with _ — required for JWT tokens, OAuth, and URL parameters.
File Encoding
Upload any file up to 2MB and get its Base64 encoding plus a ready-to-use data URI for embedding in HTML and CSS.
Swap & Reuse
Instantly swap input and output or use the output as the new input — perfect for quick encode → decode verification rounds.
Size Ratio Stats
See input size, output size, and the encoding size ratio. Base64 typically increases size by ~33%.
100% Private
All processing uses the browser's native btoa() and atob() functions. Nothing is ever sent to a server.
Frequently Asked Questions
Everything you need to know about Base64 encoding and our tool.
Base64 is a binary-to-text encoding scheme that converts binary data into 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It allows binary data to be safely transmitted over text-based protocols like email, HTTP headers, and JSON APIs.
Base64 is used to safely transmit binary data over text-only channels. Common uses include HTTP Basic Authentication headers, embedding images in HTML/CSS as data URIs, JWT tokens, email attachments via MIME, and JSON API payloads.
URL-safe Base64 replaces + with - and / with _ to make the output safe for URLs and filenames without percent-encoding. It is used in JWT tokens, OAuth, and web APIs. Toggle the "URL-safe" option in our tool to use this variant.
No. Base64 is encoding, not encryption. It is trivially reversible by anyone. Never use Base64 to protect sensitive data. Use proper encryption (AES-256, RSA) for security purposes.
Yes, 100% free. No account, sign-up, or payment required. Encode and decode unlimited Base64 strings and files at no cost, forever.
No. All encoding and decoding happens entirely in your browser using JavaScript's native btoa() and atob() functions. Your text and files never leave your device.
More Free Developer Tools
Explore more free tools from Optimizely Hub.