Text Tools
Fancy Text
Calculators
Dev Tools
More
Blog Get the Chrome extension
Free · No sign-up · Nothing is uploaded

Base64 Encode and Decode

Encode text or files to Base64 and decode them back, with emoji, URL-safe and MIME options. Nothing leaves your browser.

Input

Direction

Alphabet

Padding

Line wrap

Base64 result

Private by design. Everything runs in your browser and is never uploaded.

0 characters0 bytes0 Base64 characters0 size change

The basics

What is Base64?

Base64 is a way to write any data using only 64 printable characters: A to Z, a to z, 0 to 9, plus and slash. Every 3 bytes become 4 characters, so the result is about a third longer. It lets binary data travel through text-only channels. It is an encoding, not encryption, so anyone can decode it.

This tool encodes and decodes in both directions. Text is turned into UTF-8 bytes first, so accents, emoji and non-Latin scripts survive a round trip. To see the 0s and 1s underneath, try the binary translator.

Test values from RFC 4648, section 10
Text Bytes in hex Base64
(empty) (none) (empty)
f 66 Zg==
fo 666F Zm8=
foo 666F6F Zm9v
foob 666F6F62 Zm9vYg==
fooba 666F6F6261 Zm9vYmE=
foobar 666F6F626172 Zm9vYmFy
é C3A9 w6k=
😀 F09F9880 8J+YgA==
How it works

How to encode and decode Base64

Four steps, and the result updates as you type.

01

Pick input and direction

Choose Text or File, then Encode or Decode. In the File tab, Encode reads a file from your device and Decode rebuilds a file from Base64.

02

Set the output style

Use the standard alphabet or the URL-safe one, keep or remove the = padding, and wrap lines at 76 characters when the Base64 is for email.

03

Type, paste or drop

Text converts live as you type. Spaces and line breaks in pasted Base64 are ignored, and a bad character is named with its position.

04

Copy, download or check

Copy the result or save it as a .txt file. Open the working to see how the first bytes are regrouped from 8 bits to 6 bits.

Reference

The Base64 alphabet, padding and size

Everything the converter does comes down to these three tables.

The 64 characters (RFC 4648, tables 1 and 2)
Index Standard alphabet URL-safe alphabet
0 to 25 A to Z A to Z
26 to 51 a to z a to z
52 to 61 0 to 9 0 to 9
62 + –
63 / _
Padding = = (often left off)
How the last group of bytes is padded
Bytes in the last group Characters written Padding Example
3 4 none foo gives Zm9v
2 3 one = fo gives Zm8=
1 2 two = f gives Zg==
How much longer Base64 is: 4 characters for every 3 bytes, rounded up
Original size Bytes Base64 characters Longer by
1 KB 1,024 1,368 +33.6%
10 KB 10,240 13,656 +33.4%
100 KB 102,400 136,536 +33.3%
1 MB 1,048,576 1,398,104 +33.3%
10 MB 10,485,760 13,981,016 +33.3%
Comparison

Base64 variants and how this tool compares

Four standards use the same idea with small differences, so pick the one the receiving system expects.

Base64 variants
Variant Characters 62 and 63 Padding Line breaks Defined in
Standard Base64 + and / = None added RFC 4648, section 4
URL and filename safe – and _ = (may be omitted) None added RFC 4648, section 5
MIME (email) + and / = Lines of at most 76 characters RFC 2045, section 6.8
Data URI + and / = None RFC 2397
This tool next to typical online converters
Feature This tool Typical online converter
Encode and decode One page, same options Often a separate page for each direction
URL-safe alphabet and optional padding Both, live Not on every converter
76-character MIME wrapping With LF or CRLF line endings Offered by some, missing on others
Errors Names the bad character with line and column Often a generic message or none
Decoded images Preview before you download Often a direct download with no preview
Working shown First bytes as 8-bit and 6-bit groups Rarely
Where files are processed In your browser only Some tools process files on a server
Use cases

What people use Base64 for

Inline a small image

Turn an icon or logo into a data URI and paste it straight into HTML or CSS. RFC 2397 says the scheme is only useful for short values, so keep it for small files.

Read an encoded value

Paste a string from a config file, an API response or a log and read what it says. If the text is a long document, copy it into the online notepad to keep working on it.

Prepare email content

MIME email wraps Base64 at 76 characters per line. Switch Line wrap to 76 with CRLF and the output follows that rule.

Make data URL-safe

Choose the URL-safe alphabet and remove the padding to get a string that fits in a URL or file name without escaping.

Test emoji and accents

Encode a phrase, decode it again and check that every character survived. To spot a changed character fast, run the two versions through the text compare tool.

Rebuild a file

Paste the Base64 of a PDF, image or archive into the File tab, check the detected type and download it with the right extension.

Good to know

Things worth knowing about Base64

A few details explain most surprises. If a copied value arrives with hidden formatting, clean it first with the remove text formatting tool, or decode a binary dump with the binary to text converter.

  • Base64 is not encryption

    RFC 4648 says base encoding provides no computational confidentiality. To protect a secret, use real encryption or a strong value from the random password generator.

  • It adds about a third

    Four characters carry three bytes, so Base64 is roughly a third larger than the original, plus a little for padding and line breaks.

  • Padding completes the last group

    The = signs fill the last group of 4. RFC 4648 allows leaving them off when the length is known, so this tool accepts input without them.

  • Plain btoa breaks on emoji

    The browser function btoa throws an error for characters above U+00FF. This tool converts text to UTF-8 bytes first, so any character works.

  • Only whitespace is ignored

    Spaces and line breaks are skipped when decoding, as MIME does. Any other stray character is reported instead of silently dropped.

  • Private by design

    Reading, encoding, decoding and previewing all happen in your browser. Nothing you type or choose is sent to a server.

Limits

What this Base64 tool does not do

Size limits

Files and decoded data are capped at 10 MB. The text boxes take up to 1,000,000 characters, and the result box shows the first 20,000 characters while Copy and Download include everything.

Four text encodings

Text can be read and written as UTF-8, ISO-8859-1, UTF-16 LE or UTF-16 BE. Other legacy code pages are not included, and UTF-8 is the right choice for most data. See RFC 4648 for the encoding itself.

Decoding is not unpacking

The tool gives you the bytes back and names the file type. It does not decrypt, unzip, verify signatures or open the contents of a token. Data URIs follow RFC 2397.

Sources

Where the facts come from

The alphabets, padding and line-length rules on this page come from these references.

FAQ

Base64 FAQ

Short answers to what people ask most.

What is Base64 encoding?

Base64 writes binary data as text using 64 printable characters: A to Z, a to z, 0 to 9, plus and slash. Every 3 bytes become 4 characters, so the result is about a third longer. It is defined in RFC 4648.

How do I decode a Base64 string?

Choose Decode, then paste the Base64 into the box and the text appears as you type. Spaces, line breaks and a missing = padding are accepted, and any other invalid character is named with its position.

Is Base64 encryption?

No. Base64 is a reversible encoding with no key, and RFC 4648 notes that it provides no computational confidentiality. Anyone can decode it, so do not use it to hide passwords or private data.

Why does Base64 end with = or ==?

Base64 works in groups of 3 bytes. When the last group has 2 bytes the output ends with one =, and when it has 1 byte it ends with two ==, so the length is a multiple of 4.

Why is the Base64 version longer than the original?

Four characters carry three bytes, so the output is about 33 percent longer. Padding and optional line breaks add a little more.

What is URL-safe Base64?

URL-safe Base64 replaces + with – and / with _ so the result can sit in a URL or file name without escaping. It is defined in section 5 of RFC 4648, and the = padding is often left off.

Why does my decoded text show strange characters?

The most likely cause is the wrong text encoding. This tool reads the decoded bytes as UTF-8 by default, so if the source used UTF-16 or Latin-1, change the Text encoding option. If the bytes are not text at all, the tool says so and offers to open them as a file.

How do I convert an image or file to Base64?

Open the File tab, choose Encode, then drop your file or pick it from your device, up to 10 MB. Choose Plain Base64 or Data URI, then copy the result or download it as a .txt file.

How do I turn Base64 back into an image or file?

Open the File tab, choose Decode and paste the Base64 or a full data URI. The tool detects the file type, previews images, lets you set the file name and downloads the file.

What does the invalid character error mean?

The input contains a character outside the Base64 alphabet, such as a stray punctuation mark, a smart quote or an accidental letter. The message gives the position, line and column so you can fix it. Spaces and line breaks are ignored.

What is the 76-character line length?

MIME email, defined in RFC 2045, limits encoded lines to 76 characters. Turn on Line wrap to break the output at 76 characters, with LF or CRLF line endings.

Is my data uploaded or stored?

No. Encoding, decoding and file reading all run in your browser, and nothing you type or choose is sent to a server. Your alphabet, padding, wrap and text encoding choices are saved on your own device only.