Skip to the Base64 encoder

RFC 4648 · Encoder & decoder

Base64 encode anything, without uploading anything.

A free online Base64 encoder and decoder for text, files and images — encoded by JavaScript in your own browser tab. Nothing is uploaded, so it works offline and has no size limit.

  • Encodes as you type
  • Text, files & images
  • URL-safe & MIME modes
  • No ads, no sign-up
0 characters · 0 B
0 characters · 0 B
Options
Encoding variants

Ctrl+Enter encode Ctrl+Shift+C copy result Ctrl+Shift+X swap direction

Base64 encode online — free, instant and private

This is a Base64 encode online tool that does the work in your browser rather than on a server. Type into the box above and the Base64 appears as you go: no button, no page reload, no upload. Switch to Decode to run it in reverse, or open the File & image tab to Base64 encode an image and get a data URI you can paste straight into HTML or CSS.

Everything the standard defines is here: the standard alphabet, URL-safe Base64 (RFC 4648 §5), MIME 76-character line splitting, LF and CRLF separators, per-line encoding, and six character sets from UTF-8 through ISO-8859-1 and UTF-16. If you would rather encode base64 in code than in a browser tab, the snippets below cover Python, JavaScript, Linux, PHP, Java, Go, C# and Ruby.

Why this one

The difference is where the encoding happens.

Most Base64 tools POST your file to a server, encode it there and hand back a download link. That means your data left your machine — for a transformation your browser can do in microseconds. This one never makes that request.

Feature comparison between this Base64 encoder and typical server-based online Base64 tools
Feature freebase64encode.com Typical online encoder
Where your data is processed Your browser tab, always Uploaded to a server
File size limit Only your device memory Typically capped at 100 MB
Files stored on a server Never — there is no endpoint Held temporarily, then deleted
Works offline Yes, after the first visit No
Live encoding as you type On by default Opt-in, or a button press
Encode and decode One page, one click to swap Two separate pages
Image → data URI + HTML/CSS/Markdown Built in, with preview Not offered
Code snippets for 8 languages On the page Not offered
Size overhead shown Live byte counts and % Not shown
Ads and cookie banners None, and no tracking cookies Usually present

Do it in code

Base64 encode in Python, JavaScript, Linux and five more.

Copy-paste-ready encoding and decoding for the languages people actually search for — with the gotcha that costs everyone an afternoon called out in each one.

Python Base64 encode

Python ships Base64 in the standard library. The one thing that trips people up: b64encode takes bytes, not str, so text has to be encoded to UTF-8 first.

import base64

# Encode a string ─ note the .encode("utf-8"): b64encode takes bytes, not str
text = "Man is distinguished"
encoded = base64.b64encode(text.encode("utf-8")).decode("ascii")
print(encoded)                       # TWFuIGlzIGRpc3Rpbmd1aXNoZWQ=

# Decode it back
decoded = base64.b64decode(encoded).decode("utf-8")

# URL-safe, unpadded (RFC 4648 §5) ─ the JWT flavour
base64.urlsafe_b64encode(b"data").rstrip(b"=")

# Encode a file, wrapped at 76 characters for MIME
with open("photo.png", "rb") as f:
    mime = base64.encodebytes(f.read()).decode("ascii")

# Build a data URI for an image
uri = "data:image/png;base64," + base64.b64encode(open("photo.png", "rb").read()).decode()

The mechanics

How Base64 encoding actually works.

Base64 rewrites arbitrary bytes as 64 characters that every system on earth agrees on. It takes three bytes — 24 bits — and re-cuts them into four 6-bit groups. Each group indexes the alphabet A–Z a–z 0–9 + /. Because 3 bytes always become 4 characters, the output is exactly one third larger.

Worked example: ManTWFu

Text Man
ASCII 7797110
Bit pattern 01001101 01100001 01101110
Re-cut into 6 bits 010011 010110 000101 101110
Index 19 · 22 · 5 · 46
Base64 TWFu

When the input length is not a multiple of three, the last group is padded with = so the output stays a multiple of four. One leftover byte gives ==, two leftover bytes give =.

Where Base64 is used

Email attachments

SMTP was specified for 7-bit text. MIME (RFC 2045) Base64-encodes attachments and wraps the output at 76 characters so mail servers pass it through unchanged.

Data URIs

data:image/png;base64,… inlines a small image, font or SVG straight into HTML or CSS, saving a request. Worth it under a few kilobytes; beyond that the 33% bloat and the lost cacheability cost more than the round trip.

JSON and XML payloads

Neither format can hold arbitrary bytes. Base64 turns a file into a plain string that survives any JSON parser, which is how binary blobs travel through REST APIs.

JWTs and URLs

JSON Web Tokens use base64url — the RFC 4648 §5 variant with - and _ in place of + and / and no padding — so a token can sit safely in a URL, cookie or header.

HTTP Basic auth

Authorization: Basic is literally base64(username:password). It is encoding, not encryption — which is exactly why Basic auth is only acceptable over HTTPS.

Config and secrets files

Kubernetes Secrets, TLS certificates in PEM form and SSH keys all store binary as Base64 so the file stays a readable, diffable, copy-pasteable text file.

Six mistakes that cost people an afternoon

Base64 is not encryption

Anyone can decode it in one command. Never use it to hide a password, an API key or personal data — reach for real encryption instead.

Mismatched character sets garble text

Base64 encodes bytes, and text becomes bytes only after a character set is chosen. Encode as UTF-8 and decode as Latin-1 and you get mojibake. Keep both sides on UTF-8.

echo adds a newline

echo "hi" | base64 encodes four bytes, not two, because echo appends \n. Use printf %s to encode exactly what you typed.

Line wrapping changes the string

MIME output carries CRLF every 76 characters. Most decoders skip whitespace, but a strict comparison or hash of two "identical" strings will fail if one is wrapped.

+ and / break in URLs

+ becomes a space when a query string is form-decoded and / splits paths. Use the URL-safe variant whenever the value goes into a URL or a filename.

It grows your payload by a third

Every 3 bytes become 4 characters. Base64-ing a large upload into a JSON body inflates bandwidth and memory on both ends — send multipart/form-data instead.

Questions

Base64 encoding, answered.

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, + and /). It exists so binary data can travel safely through channels that were designed for text — email bodies, JSON and XML documents, HTTP headers, URLs and HTML attributes. Base64 is an encoding, not encryption: anyone can decode it, so it provides no confidentiality.

How do I Base64 encode text online?

Paste or type your text into the input box on this page. The result appears in the output box immediately — there is no button to press and no page reload, because encoding runs in your browser as you type. Press the Copy button, or Ctrl+Shift+C, to put the Base64 string on your clipboard.

Is this Base64 encoder safe and private?

Yes. Every byte is encoded locally by JavaScript running in your own browser tab. Your text, files and images are never transmitted to a server, never written to a database and never logged — the site is a fully static page with no upload endpoint at all. You can verify this by opening your browser DevTools Network tab while encoding, or by disconnecting from the internet and confirming the tool still works.

How do I Base64 encode in Python?

Use the built-in base64 module. Encode with base64.b64encode(data.encode("utf-8")).decode("ascii") and decode with base64.b64decode(encoded).decode("utf-8"). Note that b64encode takes bytes, not str, which is why the input is encoded to UTF-8 first. For URL-safe output use base64.urlsafe_b64encode, and for MIME output with 76-character lines use base64.encodebytes.

How do I Base64 encode in JavaScript?

For ASCII text, btoa(str) encodes and atob(str) decodes. btoa throws on characters above U+00FF, so for Unicode text first convert to bytes: btoa(String.fromCharCode(...new TextEncoder().encode(str))). In Node.js use Buffer.from(str, "utf8").toString("base64"). Modern runtimes also expose Uint8Array.prototype.toBase64().

How do I Base64 encode a file on Linux?

Use the coreutils base64 command: base64 file.txt encodes it, and base64 -d file.b64 decodes it. Add -w 0 to disable line wrapping when you need a single unbroken line, or -w 76 for MIME-compliant output. To encode a string directly, pipe it: printf %s "hello" | base64 — use printf rather than echo so no trailing newline is included in the encoded bytes.

How do I Base64 encode an image?

Open the File & image tab on this page and drop your image in. You get the raw Base64 plus a ready-to-paste data URI (data:image/png;base64,...) and generated HTML, CSS and Markdown snippets. Base64 makes an image about 33% larger, so inline images are best kept small — under roughly 5 KB — and larger images are better served as normal files that the browser can cache.

What is URL-safe Base64?

Standard Base64 uses + and / which have reserved meanings in URLs and filenames. URL-safe Base64 (RFC 4648 §5, also called base64url) substitutes - for + and _ for /, and usually drops the = padding. It is what JSON Web Tokens use. Toggle the URL-safe option on this page to produce it.

Why does my Base64 string end with = signs?

Base64 processes input in 3-byte groups that map to 4 output characters. When the input length is not a multiple of 3, the final group is padded with = so the output length stays a multiple of 4. One leftover byte produces two = characters, two leftover bytes produce one. The padding carries no data and is optional in some variants such as base64url.

How much larger does Base64 make my data?

About 33% larger — every 3 bytes of input become 4 characters of output, a ratio of 4/3. Line breaks in MIME mode add a further ~1.4%. This tool shows the exact input size, output size and overhead percentage under the output box as you type.

Is there a file size limit?

There is no server-side limit because there is no server involved. The practical ceiling is your device memory and browser tab limits; files up to a few hundred megabytes generally work on desktop, and this tool streams large files in chunks so the browser stays responsive. Competing tools that upload to a server typically cap you at 100 MB.

Does Base64 encoding work with Unicode and emoji?

Yes. Text is converted to bytes first using the character set you select — UTF-8 by default, which covers every Unicode code point including emoji — and those bytes are then Base64 encoded. Mismatched character sets between the encoder and decoder are the usual cause of garbled output, so keep both on UTF-8 unless you have a specific reason not to.

Last updated August 2026

The short version

This site does not collect your data, because it never receives it. All Base64 encoding and decoding happens inside your browser using JavaScript. Your text, files and images are never transmitted anywhere.

What we do not collect

No accounts, no email addresses, no names. We do not read, store, log or transmit the content you paste or the files you select. There is no upload endpoint on this site — you can confirm this yourself in your browser’s DevTools Network tab, or by disconnecting from the internet and watching the tool keep working.

Cookies and local storage

This site sets no cookies and stores nothing in localStorage. No consent banner is shown because there is nothing to consent to.

Analytics and advertising

There are no advertising networks, no third-party trackers, no fingerprinting scripts and no social media pixels on this page.

Hosting and server logs

The site is a static page served by our hosting provider. Like any web host, they may record standard request metadata such as IP address, timestamp and user agent for security and abuse prevention. We do not use that data for profiling or share it, and it never contains anything you typed into the tool.

Fonts and third-party requests

Fonts are self-hosted from this domain, so loading the page does not send a request to any third party.

Children

This is a general-purpose developer utility and is not directed at children under 13. Since no personal data is collected from anyone, none is collected from children either.

Changes

If this policy changes, the date above changes with it.

Contact

Questions about privacy: hello@freebase64encode.com

Last updated August 2026

Acceptance

By using freebase64encode.com you agree to these terms. If you do not agree, please do not use the site.

The service

This site provides a free client-side Base64 encoder and decoder plus reference documentation. It is offered as-is for anyone to use, personally or commercially, with no registration and no fee.

No warranty

The tool is provided "as is" and "as available", without warranty of any kind, express or implied, including merchantability, fitness for a particular purpose and non-infringement. We do not warrant that the site will be uninterrupted or error-free.

Verify before you rely

Base64 conversions are deterministic and this implementation follows RFC 4648, but you remain responsible for verifying results before using them in production systems. Do not use this tool as the sole check for anything safety-critical.

Limitation of liability

To the maximum extent permitted by law, we are not liable for any loss of data, profit, or any indirect, incidental or consequential damages arising from your use of this site.

Acceptable use

Do not use this site to break the law, to attack or overload the infrastructure serving it, or to process data you have no right to process. Automated scraping that degrades the service for others is not permitted.

Base64 is not security

Base64 is an encoding, not encryption. Encoding a secret does not protect it. You are responsible for how you handle sensitive data.

Intellectual property

The site design, written documentation and code examples are ours. The code snippets shown on the page are short reference examples and you are free to use them in your own projects without attribution.

Changes

These terms may be updated; continued use after a change means you accept the updated terms.

Why this exists

The problem

Most online Base64 tools upload your file to a server, encode it there, and hand back a download link — for an operation your own browser performs in microseconds. If the file is a client contract, an API key dump or a private key, that upload is the whole problem.

The approach

freebase64encode.com is a single static HTML page. The encoder is a few kilobytes of JavaScript implementing RFC 4648 directly. There is no backend, no database and no upload endpoint, so there is nothing to breach and nothing to log.

What it handles

Text in six character sets, files of any size your device can hold, and images with a live preview plus a ready-to-paste data URI. It supports the standard alphabet, the URL-safe alphabet from RFC 4648 §5, MIME 76-character line splitting, LF and CRLF separators, and per-line encoding.

Standards

Base64 is specified in RFC 4648. The MIME variant with 76-character lines comes from RFC 2045. The URL-safe variant used by JSON Web Tokens is RFC 4648 §5.

Cost

Free, with no ads, no upsell and no account. It stays that way.

Bugs, corrections and requests

Email

Write to hello@freebase64encode.com. Bug reports, wrong output, a character set you need, or a language you would like a snippet for are all welcome.

Reporting a bug

The most useful report includes the exact input, the options you had selected (character set, URL-safe, line splitting), what you expected, what you got, and your browser and version.

A note on the documentation

If you spot an error in the code examples or the explanation of how Base64 works, please say so — accuracy on those pages matters more to us than anything else on the site.

What we cannot do

We cannot recover data you encoded here. Nothing is stored, so there is no history to retrieve.