Base64 Encoder

Encode text or files to Base64, with URL-safe output when you need it.

  • Runs in your browser
  • Free, no sign-up
Type text to start

About the Base64 Encoder

Base64 turns any data, whether text, an image or a PDF, into a string of plain letters, digits and a few symbols. That makes it safe to put binary data where only text is allowed: inside JSON, an email, an HTML or CSS file, a URL or an HTTP header.

Type text and the Base64 Encoder converts it as you type. The text is first turned into UTF-8 bytes, so accented letters, other alphabets and emoji all encode correctly. Switch to File to encode an image, a font or any other file up to 10 MB, and optionally get a ready-to-use data URL.

Options cover the common variants: URL-safe Base64 with - and _, output without = padding, and line breaks every 76 characters for email. Everything is encoded in your browser, so your text and files never leave your device.

How to use it

  1. Choose Text or FileText encodes what you type. File encodes the exact bytes of a file you choose or drop.
  2. Add your inputType or paste text, or drop a file on the drop zone. Dropping a file onto the text box switches to File mode automatically.
  3. Pick a variantTurn on URL-safe for links and tokens, No = padding if the receiving system expects it, or line breaks for email.
  4. Get a data URLIn File mode, turn on "Output as a data URL" to get data:type;base64,... for use in HTML or CSS.
  5. Copy or downloadThe status line shows the input size and the output length. Copy the Base64 or download it as a text file.

Key features

UTF-8 text

Text is encoded as UTF-8, the standard on the web, so "Grüße", "München" and 👋 come out the same as in any other modern tool.

Any file

Images, PDFs, fonts, archives or any other file up to 10 MB, byte for byte.

URL-safe variant

Replaces + with - and / with _ so the result can go into a URL or a file name without escaping.

Padding and line breaks

Remove the trailing = signs, or wrap lines at 76 characters as MIME email requires.

Data URLs

Get a complete data URL with the file's type, ready to paste into an img tag or a CSS background.

Private by design

Nothing is uploaded. Encoding happens on your device, even for files.

Examples

Encoding text

TextBytesBase64
Hello5SGVsbG8=
Hello, world!13SGVsbG8sIHdvcmxkIQ==
café5Y2Fmw6k=
👋48J+Riw==

"café" has four letters but five bytes, because é takes two bytes in UTF-8. The Sample button encodes "Hello, world! Grüße aus München 👋": 39 bytes in, 52 characters out.

Why some results end in =

Base64 turns every 3 bytes into 4 characters. When the input does not divide evenly by 3, = signs fill up the last group:

TextBase64Padding
MTQ==2 = signs
MaTWE=1 = sign
ManTWFunone

URL-safe Base64

Standard Base64 of <<???>> is PDw/Pz8+Pg==. The / and + would need escaping in a URL. With URL-safe and No = padding turned on, you get PDw_Pz8-Pg, the form used in JSON Web Tokens and many web APIs.

An HTTP Basic authentication header

Basic authentication sends the user name and password as Base64. Encoding user:pass gives dXNlcjpwYXNz, so the header is:

Authorization: Basic dXNlcjpwYXNz

Anyone who sees the header can decode it, which is why Basic authentication should only be used over HTTPS.

A small image as a data URL

Encoding a 62-byte SVG file gives 84 characters of Base64. With "Output as a data URL" on, the result starts with data:image/svg+xml;base64, and is 110 characters long. You can use it directly in CSS:

background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...");

Tips

  • Expect Base64 to be about a third larger than the original. A 30 KB image becomes about 40 KB of text, so data URLs only pay off for small icons and images.
  • Use URL-safe Base64 whenever the result goes into a link, a query string, a cookie or a file name. Standard + and / characters can be changed or misread there.
  • If another system rejects your Base64, check whether it expects padding. JSON Web Tokens leave out the = signs; most other formats keep them.
  • Turn on line breaks only for email attachments and other MIME content, which allow at most 76 characters per line. JSON, HTML and APIs expect the Base64 on one line.
  • To check your result, paste it into the Base64 Decoder. It should give back exactly the text or file you started with.

Common mistakes and limits

  • Treating Base64 as encryptionBase64 hides nothing. Anyone can decode it in a second. Never use it to protect passwords, keys or personal data.
  • Mixing up character encodingsThis tool encodes text as UTF-8. Some older systems expect Latin-1 or UTF-16, and the same text then gives different Base64, especially for accented letters.
  • Expecting data URL options to applyData URLs always use standard Base64 with padding and no line breaks, so the URL-safe, padding and line break options are ignored in that mode.
  • Encoding very large files as data URLsBig data URLs make HTML and CSS files heavy and cannot be cached separately. Link to the file instead when it is more than a few kilobytes.
  • Copying invisible line breaksWith line breaks turned on, the output contains new lines. Many APIs and JSON parsers reject Base64 with line breaks in it.

Frequently asked questions

What is Base64 encoding?
A way to write any data using only 64 safe characters: A to Z, a to z, 0 to 9, + and /, with = for padding. It is used to carry binary data, such as images or attachments, through systems that only handle text.
Why is Base64 longer than the original?
Every 3 bytes become 4 characters, so the output is about 33% larger. With line breaks every 76 characters, it grows a little more.
What is URL-safe Base64?
A variant that uses - instead of + and _ instead of /, so the result can go into a URL or a file name unchanged. It is defined in RFC 4648 and used in JSON Web Tokens.
What does the = at the end mean?
It is padding. It shows that the last group held only one or two bytes instead of three. Some formats leave it out; decoders can usually work without it.
Can I encode images and other files?
Yes. Switch to File and choose or drop any file up to 10 MB. The exact bytes are encoded, whatever the file type.
What is a data URL?
A link that contains the file itself, such as data:image/png;base64,iVBOR... Browsers can show it like a normal image or font, without a separate download.
Does it work with emoji and other languages?
Yes. Text is encoded as UTF-8, so every language and emoji is supported. 👋, for example, is 4 bytes and becomes 8J+Riw==.
Is my data uploaded?
No. Text and files are encoded in your browser. Nothing is sent to a server.