Base64 Encoder — Text to Base64, Standard or URL-Safe

Paste text to encode it as Base64, using the standard or URL-safe alphabet, with or without = padding and line breaks, and see how much longer the result is.

Live demo · real result from this tool
Alphabet

Base64

VG9vbHNSaWZ0IGVuY29kZXMgdGV4dCBhcyBVVEYtOCBmaXJzdCwgc28gY2Fmw6ksIOCkqOCkruCkuOCljeCkpOClhyBhbmQg8J+RiyByb3VuZC10cmlwIGV4YWN0bHku
Input
96 B
Output length
128 characters

Processed on your device — nothing is uploaded.

How to use the Base64 encoder

  1. Type or paste your text into Text to encode.
  2. Choose the Alphabet: Standard (+/) or URL-safe (-_).
  3. Pick a Line length: No line breaks, 76 (MIME) or 64 (PEM).
  4. Untick Keep = padding if the system you are sending to does not want it.
  5. Copy the Base64 output. The stats show the input size in bytes and the output length in characters.

What it does and when to use it

Base64 lets you carry any data through a channel that only accepts plain text. You will meet it when you:

  • Put credentials in an HTTP Basic Authorization header, which is the username and password joined by a colon and Base64-encoded.
  • Store a small binary value, or text with tricky characters, in JSON, YAML or an environment variable.
  • Build or test a JWT, whose header and payload are URL-safe Base64.
  • Create email content or data URIs by hand.

To reverse the process, use the Base64 Decoder. If your text is going into a query string rather than a header, the URL Encoder is usually what you need instead. For a more compact text encoding of binary data with a different alphabet, see Base32.

How it works

  1. Your text is converted to UTF-8 bytes. Plain English letters are one byte each, accented letters two, and most emoji four.
  2. The bytes are taken in groups of three (24 bits) and split into four groups of 6 bits.
  3. Each 6-bit value (0 to 63) is written as one character: A–Z, a–z, 0–9, then + and / (or - and _ in the URL-safe alphabet).
  4. If the last group is short, = signs pad the output to a multiple of four characters, unless you turn padding off.

This follows RFC 4648, the standard that defines Base64 and the URL-safe variant. Everything runs in your browser.

Worked examples

A classic. “Hello, world!” encodes to SGVsbG8sIHdvcmxkIQ==. The 13 input bytes become 20 characters, shown as Output length: 20 characters, including two = signs of padding.

Accents and emoji, URL-safe, no padding. “café 👋” is 10 UTF-8 bytes (é takes two and 👋 takes four). In the URL-safe alphabet without padding it becomes Y2Fmw6kg8J-Riw. Note the - where standard Base64 would use +.

Exactly three bytes. “Man” fills one group perfectly and encodes to TWFu, with no padding.

Limits and tips

  • The same text always gives the same Base64, so it is not a way to make something unique or secret.
  • Different systems disagree about padding and line breaks. If a receiver rejects your value, try toggling padding first.
  • Text is always encoded as UTF-8. If a system expects another character set, the result will not match.

Frequently asked questions

Is Base64 a form of encryption?
No. Base64 has no key, and anyone can decode it instantly. It only changes how bytes are written so they can travel through systems that expect plain text. Never use it to hide a password or token.
Why is the Base64 output longer than my text?
Base64 writes every 3 bytes as 4 characters, so the output is about a third longer than the input, plus up to two = signs of padding. "Hello, world!" is 13 bytes and becomes 20 characters.
When should I use the URL-safe alphabet?
When the result goes into a URL, a file name or a token such as a JWT. Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe alphabet uses - and _ instead, and padding is usually left off.
What do the line length options do?
Some formats expect Base64 split into fixed-length lines. 76 characters is the MIME limit used in email, and 64 is used in PEM files such as certificates. Choose No line breaks for JSON, URLs and most other uses.
Can I encode an image or a file here?
This tool encodes text. To turn an image into a Base64 data URI, use the image tools. To go the other way and preview Base64 as an image, use Base64 to Image.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close