How to Encode Text to Base64
- Paste or type your text — Enter any text into the input field. With Live mode on, encoding happens instantly as you type.
- Choose your options — Enable URL-safe encoding for use in URLs and JWT tokens. Use line-by-line mode to encode multiple values at once.
- Copy or download — Copy the Base64 output to your clipboard or download it as a .txt file.
How to Encode a File to Base64
- Switch to the File tab — Click the File tab above the tool.
- Upload your file — Drag and drop any file (image, PDF, document, audio) onto the upload zone or click to browse.
- Choose output format — Toggle the data URI prefix option on to get a ready-to-use
data:image/png;base64,...string for embedding in HTML/CSS, or off for the raw Base64 string. - Copy or download — Copy the output or save it as a .txt file.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts any data — text, images, files — into a safe sequence of 64 printable ASCII characters. The name comes from the 64 characters used: A–Z, a–z, 0–9, plus (+), and forward slash (/), with equals (=) for padding.
Base64 doesn’t compress or encrypt your data. It represents it in a different format that can safely travel through systems that only support ASCII text — like email protocols, JSON APIs, and HTML attributes.
Common Uses for Base64 Encoding
- Data URIs — Embed images directly in HTML or CSS without separate file requests:
<img src="data:image/png;base64,..."> - Email attachments — MIME encoding uses Base64 to transmit binary attachments through text-based email protocols
- HTTP Basic Auth — Credentials are Base64-encoded in Authorization headers:
Authorization: Basic dXNlcjpwYXNz - JWT tokens — JSON Web Tokens use URL-safe Base64 to encode header and payload sections
- API payloads — Binary data embedded in JSON, XML, or other text-based formats
- Configuration files — Encoding secrets and keys for environment variables
URL-Safe Base64 vs Standard Base64
Standard Base64 uses + and / characters which are reserved in URLs and query strings. URL-safe Base64 (Base64URL) replaces + with - and / with _, making the output safe to use directly in URLs without percent-encoding. Use URL-safe mode when generating tokens, encoding URL parameters, or working with JWT tokens.