Base64 Encoder: Encode Text, PDF & Files Online
Encode UTF-8 text or any file (PDF, DOCX, XLSX, ZIP up to 50 MB) to Base64 or Base64URL. Runs in your browser, nothing is uploaded. Free, no sign-up.
Updated November 2026
Reviewed by Rafael Duarte
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
Click Copy to send the output to your clipboard. Shift + Enter also copies, but only when the cursor is not in the text box.
What this base64 encoder can do
More than plain text
Encodes any file type
Drop a PDF, XLSX, DOCX, ZIP or any other file up to 50 MB. It's read locally in your browser, nothing gets uploaded to a server.
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().
Runs 100% in your browser
Encoding happens on your device: no account, no upload, no server round-trip.
Output ready to paste into an API
The result is a raw Base64 string with no line breaks and no data: prefix, the same as server-side base64_encode() would produce.
Examples
Text and files, side by side
data: prefix)When you'll reach for this
The most common scenarios among people who use this tool
Attach a PDF to JSON
When an API takes documents inside a JSON body instead of a multipart upload, the PDF goes in as a Base64 string field.
Spreadsheet into an API payload
Same idea for Excel or CSV files: encode the file in File mode and paste the string into the request.
Basic Auth header
The username:password pair gets Base64-encoded before it goes into the Authorization header.
Inline image in HTML or CSS
A data URI (data:image/png;base64,...) needs the prefix in front of the Base64 string, and this encoder outputs the raw string only. For images, use Image to Base64, which builds the full data URI for you.
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 decoding gives you Base64 back instead of your data.
Base64 vs Base64URL
Standard Base64 uses + and /; URL-safe swaps them for - and _ and drops the =. The two are not interchangeable, so turn on URL-safe (Base64URL) only when the target is a JWT or a URL.
Pasting the raw string where a data URI is expected
An src attribute or CSS url() needs data:<type>;base64, before the string. This tool doesn't add it, so either type the prefix yourself or use Image to Base64 for images.
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: your text or file is never uploaded, which matters when the PDF is a contract or the string is a private key.
Unlike plain btoa(), this tool handles UTF-8 correctly and accepts whole binary files up to 50 MB, not just short strings. By default the output is standard Base64, the same as any server-side library produces, so there are no surprises when you paste it into your API. For JWTs and URL parameters, the URL-safe (Base64URL) option produces the -/_ variant without padding. New to the format? Read What Is Base64?.
Frequently asked questions
Yes. Switch to File mode, drop the PDF (up to 50 MB) and click Copy. The result is a raw Base64 string that starts with JVBERi0, ready to paste into an API payload. The file never leaves your browser.
Encode the PDF in File mode, copy the output and put it in the string field your API documents, for example {"file": "JVBERi0x…"}. The output is the bare string, without a data:application/pdf;base64, prefix; add that prefix only if the API explicitly asks for a data URI.
Yes. File mode accepts any file type up to 50 MB. The output is raw Base64, the same as server-side base64_encode() would produce (or Base64URL, if that option is on).
No. It's encoding, not encryption: anyone with the string can decode it instantly, with no key needed. Never use it to protect passwords or secrets.
Yes. It combines encodeURIComponent with btoa to correctly handle the full UTF-8 range, including accented letters, CJK characters, and emoji.
Standard Base64 uses + and /. Base64URL replaces them with - and _, making the string safe for URLs and filenames; it's what JWTs use. To get that format here, tick URL-safe (Base64URL): + becomes -, / becomes _, and the = padding is removed.
About 33% bigger, because every 3 bytes of input become 4 Base64 characters. A 1 KB file (1,024 bytes) encodes to 1,368 characters, roughly 1.34 KB, since this tool doesn't add line breaks. The Size card under the output shows the result in KB.
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 Decode Online — Free Base64 to Text 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 Converter: Data URI, HTML & CSS Developer Drop a PNG, JPG, WebP, GIF or SVG up to 20 MB and copy raw Base64, a data URL, an <img> tag or a CSS url(). Runs in your browser, nothing uploaded.
- Base64 to Image Online: Preview and Save PNG, JPG, GIF Developer Paste raw Base64 or a data:image URL to preview the image with its type, dimensions and size, then save the original file. No upload, runs in your browser.
- HTML Entity Encoder: Escape HTML Characters Online Developer Escape <, >, &, quotes and accents as HTML entities (<, &, é) in Essential, Named or Numeric mode. Runs entirely in your browser.
- URL Encoder: Encode Query Strings, Spaces & UTF-8 Developer Turn spaces, accents and symbols into %20, %C3%A9 and %26 for links and query strings, with spaces as %20 or +. Runs locally in your browser.