Base64 Encoder
Encode any text or string to Base64 instantly in your browser. Supports UTF-8, shows character count and output payload size. Free, no signup, 100% client-side.
Updated May 2026
How this base64 encoder works
Text or file, three steps
1. Paste text or drop a file
Switch to Text mode to paste any string, or File mode to drag in a PDF, XLSX, DOCX, ZIP, or image.
2. See the result instantly
The Base64 string appears right away, with a green valid badge once it's ready.
3. Copy it
One click on Copy (or Shift+Enter) sends the output straight to your clipboard.
What this base64 encoder can do
More than plain text
Encodes UTF-8 text correctly
Uses encodeURIComponent combined with btoa, so accented letters, CJK characters, and emoji don't break like they would with plain btoa().
Encodes any file type
Drop a PDF, XLSX, DOCX, ZIP, or image up to 50 MB — it's read locally, nothing gets uploaded to a server.
Runs 100% in your browser
Nothing leaves your device — encoding happens locally, and the page keeps working offline once it's loaded.
Output ready to paste into an API
The result is a raw Base64 string, identical to what server-side base64_encode() would produce.
Examples
Text and files, side by side
When you'll reach for this
The most common scenarios among people who use this tool
Attach a PDF to JSON
Payment and e-signature APIs often expect a base64_content field somewhere in the request body.
Spreadsheet into an API payload
Finance and reporting systems frequently accept Excel files as a Base64 string instead of a multipart upload.
Basic Auth header
The username:password pair gets Base64-encoded before it goes into the Authorization header.
Inline image in HTML or CSS
Data URIs (data:image/png;base64,...) skip an extra network request for small icons and logos.
Debugging a JWT
Encode JSON to check exactly what a token segment should look like before you sign it.
Secrets in a .env file
An encoded certificate or private key travels as a single-line string in any config file or CI secret.
Not what you expected? Start here
Double encoding
Never encode an output that's already Base64 — always start from the original raw value, or you'll get garbage on decode.
Base64 vs Base64URL
Standard Base64 uses + and /; URL-safe swaps them for - and _. The two are not interchangeable.
Mistaking it for encryption
Base64 is encoding, not security — anyone can decode it instantly with no key required. Never use it to protect passwords or secrets.
Skipping the UTF-8 step
Plain btoa() breaks on anything outside Latin-1 — this tool already handles that for you.
Why encode here
Everything runs locally in your browser — no byte of your text or file ever leaves your device, and the page keeps working offline once it's loaded.
Unlike plain btoa(), this tool already handles UTF-8 correctly and accepts whole binary files up to 50 MB, not just short strings — and the output is always standard Base64, identical to what any server-side library produces, so there are no surprises when you paste it into your API.
Frequently asked questions
Yes — switch to File mode, drop the PDF, and copy the output. The result is a raw Base64 string ready to paste into any API payload.
References
Official browser API documentation for the function that performs Base64 encoding.
The IETF standard that formally defines Base64 and its variants, including Base64URL.
A guide on correctly handling Unicode and the UTF-8 step when encoding in JavaScript.
Related Tools
- Base64 Decoder Developer Free online Base64 decoder — decode Base64 strings back to plain text instantly in your browser. Validates input and shows decoded payload size.
- Image to Base64 Developer Upload any image and convert it to a Base64 data URL ready for HTML, CSS, or JSON — free online converter supporting PNG, JPEG, SVG, WebP. No server upload.
- Base64 to Image Developer Paste a Base64 string or data URL and instantly preview the decoded image — free online converter supporting PNG, JPEG, WebP, GIF, SVG. No upload, runs locally.
- HTML Entity Encoder Developer Encode text to HTML entities online — escape special characters like <, >, &, and " instantly in your browser. No install needed.
- URL Encoder Developer Encode any URL or text to percent-encoding instantly in your browser. Follows RFC 3986. Free, no sign-up required.