Base64 Encoder: Encode Text, PDF & Files Online

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

Shift + Enter to Copy · Shift + ← → for tabs
Input String
0 characters
Base64 Output
Speed
—
Privacy
Local Only
Size
0 KB

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

Input
Base64 output
Hello
SGVsbG8=
hello world
aGVsbG8gd29ybGQ=
{"user":"admin"}
eyJ1c2VyIjoiYWRtaW4ifQ==
café
Y2Fmw6k=
(PDF file)
JVBERi0x… (raw string, no 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.

References

Related Tools