Base64 Encoder & Decoder
How to Use This Base64 Encoder/Decoder
- Pick Text Mode or File ModeChoose between Text Mode and File Mode using the tabs at the top. Text Mode handles plain text and string encoding, while File Mode works with any file type including images, PDFs, and documents.
- Encode or decode textIn Text Mode, select Encode or Decode, then type or paste your content. Encoding converts readable text into a Base64 string. Decoding converts a Base64 string back into readable text. The conversion happens instantly as you type.
- Convert files to Base64In File Mode, drag and drop a file (or click to browse) to encode it to Base64. The tool reads the file, converts it, and displays the full Base64 string. Toggle "Include data URI prefix" to prepend the standard
data:mime;base64,header used in HTML and CSS. For images, a preview is shown automatically. - Decode Base64 back to a fileTo decode a Base64 string back to a file, switch to Decode mode in File Mode, paste the Base64 string, and click "Download Decoded File." The tool auto-detects the file type from the data URI prefix if present.
- Use URL-safe output and copy controlsEnable URL-safe Base64 for strings that will be used in URLs or filenames - this replaces characters that have special meaning in URLs. Click "Copy Output" to copy the result, "Swap" to reverse the operation, or "Download as .txt" to save long outputs as a text file.
All processing happens locally in your browser. No data is ever sent to a server.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses 64 characters — the uppercase and lowercase Latin letters (A–Z, a–z), digits (0–9), plus (+), and forward slash (/) — with equals (=) used for padding. This limited character set ensures the encoded data can be safely transmitted through systems that only handle text, which is why a Base64 encoder/decoder is indispensable for web developers and API users.
The Base64 alphabet
How the 3-to-4 conversion works
The encoding works by taking three bytes (24 bits) of binary data and splitting them into four 6-bit groups. Each 6-bit group maps to one of the 64 characters. This means Base64 encoded data is always approximately 33% larger than the original binary data — three input bytes become four output characters.
Data URIs and inline images
The most common use of Base64 in web development is embedding images directly in HTML or CSS. Instead of linking to an external image file, you can include the image data inline as a data URI: data:image/png;base64,iVBOR... This eliminates an HTTP request but increases the HTML file size. It's most effective for small images like icons.
Where Base64 shows up
Base64 is also essential in email (MIME encoding), JSON Web Tokens (JWT), API authentication headers (Basic Auth), and storing binary data in text-only formats like XML and JSON. While Base64 makes binary data text-safe, it is not encryption — Base64 can be trivially decoded by anyone.
URL-safe Base64
URL-safe Base64 is a variant that replaces + with - and / with _ to avoid conflicts with URL syntax. This variant is used in JWT tokens, URL parameters, and filenames where the standard Base64 characters would cause parsing issues.
Base64 Tool Features
- Text modeEncode and decode strings in real time as you type.
- File modeDrag-and-drop any file (image, PDF, audio, archive) to get its Base64 string.
- Image previewSee the image you are encoding or decoding before copying.
- Data URI toggleAdd or remove the
data:mime;base64,prefix with one click. - URL-safe Base64Produce JWT/OAuth-ready strings with
-,_, and no padding. - Auto MIME detectionDecoding automatically picks the right file extension (png, jpg, pdf, mp3…).
- Copy, swap, and downloadOne-tap controls including saving long outputs as
.txt. - Runs offlineAll encoding/decoding happens in your browser with no network traffic.
Common Uses for a Base64 Encoder/Decoder
- Inline images in HTML & CSSEmbed small icons or SVGs as
data:image/png;base64,...to cut HTTP requests. - Decode JWT tokensJWT payload is Base64url-encoded JSON; decode it here, then format the JSON in our JSON Formatter.
- HTTP Basic Auth headersBuild the
Authorization: Basic <base64(user:pass)>header for API testing with cURL or Postman. - Email attachments (MIME)Inspect or craft base64-encoded MIME parts in raw email messages.
- Mobile app / SDK assetsBundle small images or fonts as base64 strings inside app config.
- Webhooks & APIsAPIs like Stripe, Twilio, and Slack sometimes accept or return base64 payloads for files.
- QR code payloadsGenerate a compact base64 string before encoding it into a QR code with our QR Code Generator.
- Database BLOB workaroundsStore binary data inside text columns that do not support BLOB types.