Base64 Encoder & Decoder — Text and File Converter
Encode any text or file to Base64 instantly, or decode a Base64 string back to readable text. Includes URL-safe mode for JWT tokens and OAuth flows, plus file-to-Data URI output for images and PDFs. Free, browser-based, no signup required.
Drag & drop any file here,
or browse to select
Images, PDFs, fonts, documents…
How to Use the Base64 Encoder and Decoder
- Select the Text ↔ Base64 tab to encode or decode plain text.
- Choose a mode: Auto-detect inspects your input and picks encode or decode automatically; or select manually.
- Enable URL-safe Base64 to replace + and / with - and _ for use in JWT tokens, OAuth PKCE challenges, and URL query strings.
- Switch to the File → Base64 tab and drag any file onto the drop zone for file encoding.
- Choose an output format: Raw Base64, Data URI, HTML img tag, or CSS background-image declaration.
- Click Copy Output to copy the result to your clipboard.
Key Features
- Live encode and decode as you type with input and output character counts
- Auto-detect mode — intelligently picks encode or decode based on input content
- URL-safe Base64 (RFC 4648 §5) with + → - and / → _ substitution
- Correct UTF-8 / Unicode handling for emoji, CJK, and accented characters
- Swap Input/Output button to instantly reverse the operation
- File tab encodes any file type: images, PDFs, fonts, audio, documents
- Four output formats for files: Raw Base64, Data URI, HTML img tag, CSS declaration
- 100% browser-based — no files or text ever uploaded to a server
Base64 Encoder Use Cases
Encoding JWT tokens and OAuth 2.0 PKCE challenges
JSON Web Tokens use Base64url encoding for the header and payload sections. The URL-safe mode removes the + and / characters that would break URL parsing, making the output safe for Authorization headers and cookie values without percent-encoding.
Embedding images in HTML email templates
Many email clients block external image requests for privacy. Embedding small images as Base64 Data URIs in the img src attribute of your HTML email template ensures they load immediately even in offline or restricted environments, without requiring an image hosting server.
Converting files to Data URIs for single-file HTML
Single-file HTML documents — documentation, dashboards, or offline reports — can embed fonts, images, and scripts as Data URIs, eliminating all external dependencies so the file works anywhere without an internet connection.
Passing binary data through text-only channels
SMTP email, JSON APIs, and XML documents cannot carry raw binary data. Base64 encoding converts binary content (images, PDFs, certificates) to a string that passes safely through any text-based protocol.
FAQ's
Standard Base64 uses + and / characters that are reserved in URLs. URL-safe Base64 (RFC 4648 §5) replaces + with - and / with _, and omits the = padding. This makes the output safe for URL query strings, HTTP headers, and file names without percent-encoding.
Auto-detect tests whether your entire input matches the Base64 character set (A–Z, a–z, 0–9, +, /, =, and whitespace). If it matches, the tool suggests Decode; otherwise it suggests Encode. You can always override the detected direction manually.
Yes. The encoder uses encodeURIComponent and unescape to correctly handle multi-byte UTF-8 characters including emoji, CJK characters, and accented letters before encoding to Base64. The decoder reverses this process exactly.
A Data URI embeds file content directly in a URL using the format data:[MIME type];base64,[data]. Browsers treat it like an external URL, so you can use it as an img src, CSS background-image url(), or href attribute. The MIME type tells the browser how to interpret the data.
No. All encoding uses the browser's FileReader API entirely client-side. Your files and text never leave your device and are never transmitted to any server. The tool works offline once the page has loaded.
Base64 encodes 3 bytes of binary data as 4 ASCII characters, resulting in a 4/3 (33.3%) size overhead. This is a fundamental property of the encoding scheme, not a bug. For large files this overhead is significant, so Base64 is best suited for small assets.
Any file type your browser can read via FileReader — images (JPEG, PNG, WebP, GIF, SVG), PDFs, fonts (TTF, WOFF), audio files, and plain text documents. The MIME type is automatically detected from the file and included in the Data URI output.