Upload a file
  1. base64hub
  2. Text tools
  3. MIME encoder

MIME Base64 Encoder with 76-Character Lines

Paste text and get Base64 broken into 76-character lines, the format email bodies and attachments use. Switch to 64 for PEM blocks or to None for a single line.

Free no sign-up, no limits Local nothing uploaded 76 characters per line, RFC 2045 Updated Oct 27, 2026
Input 0 BOutput 0 BSize –

Processed in your browser. This page cannot send your data anywhere – how we know

How to create MIME Base64

  1. Paste the text into Input · text. Line wrap is preset to 76 (MIME, LF).
  2. Keep Charset on UTF-8 unless the message declares another charset, and use the same value in the Content-Type header.
  3. Copy the wrapped Base64 from Output · Base64, or Download it as base64.txt.
  4. For certificate or key bodies, switch Line wrap to 64 (PEM). For HTTP, JSON or anything else that wants one line, choose None.

What MIME Base64 is

MIME (RFC 2045) is the standard that lets email carry attachments, non-English text and HTML. When a part’s body is binary or full of non-ASCII bytes, the sender encodes it as Base64 and marks it with Content-Transfer-Encoding: base64. On top of plain Base64, RFC 2045 adds a line-length rule: encoded lines may be at most 76 characters long. A 76-character line holds 57 input bytes.

A text part encoded this way looks like this; the two Base64 lines are this tool’s output for the sentence quoted below:

Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64

Q2Fmw6kgbWVudTogY3LDqG1lIGJyw7tsw6llLCBqYWxhcGXDsW8sIHNtw7ZyZ8Olc2JvcmQuIFRo
aXMgbGluZSBpcyBsb25nIGVub3VnaCB0byB3cmFwIGFmdGVyIDc2IGNoYXJhY3RlcnMu

The original text was Café menu: crème brûlée, jalapeño, smörgåsbord. This line is long enough to wrap after 76 characters., 108 bytes in UTF-8. Decoded with the Base64 decoder, both lines together give the sentence back; the line break is ignored.

Line breaks, CRLF and size

Line wrap offers two 76-column variants: 76 (MIME, LF) separates lines with a line feed (\n), and 76 (MIME, CRLF) uses \r\n. Email on the wire uses CRLF, and mail libraries convert line endings when they serialize a message, so LF is fine for code. If you paste the output straight into a raw .eml file or an SMTP session, pick the CRLF variant.

Wrapping costs a little extra space on top of the usual 33%:

OutputCharacters per 57 input bytesOverhead
One line, no breaks7633.3%
76-character lines with LF7735.1%
76-character lines with CRLF7836.8%

Mail size limits apply to the encoded message, so a 10 MB attachment needs roughly 13.7 MB of the limit. The size calculator gives exact figures, and Base64 in email explains how the parts fit together.

Encoded-words for headers

Headers such as Subject and From cannot use Content-Transfer-Encoding. Non-ASCII header text uses RFC 2047 encoded-words: =?charset?B?base64?=. To build one, encode the text with Line wrap set to None and wrap the result yourself:

Subject: =?UTF-8?B?R3LDvMOfZSBhdXMgQmVybGlu?=

That decodes to Grüße aus Berlin. One encoded-word may be at most 75 characters long; longer subjects are split into several encoded-words separated by a space. For text that is mostly ASCII, mail software often uses the ?Q? form instead, which is based on quoted-printable.

MIME Base64 in code and on the command line

Python’s base64.encodebytes wraps at 76 characters with \n, giving the same lines as this tool:

import base64

text = "Café menu: crème brûlée, jalapeño, smörgåsbord. This line is long enough to wrap after 76 characters."
print(base64.encodebytes(text.encode("utf-8")).decode("ascii"))

For whole messages, the email package handles encoding, headers and CRLF for you. On Linux, GNU base64 wraps at 76 by default and openssl base64 at 64:

base64 attachment.pdf > attachment.b64
openssl base64 -in attachment.pdf -out attachment.pem.b64

To take a raw email apart instead, open it in the email (EML) decoder, which pulls out the bodies and attachments.

FAQ

Why does MIME Base64 use 76-character lines?

RFC 2045 sets the limit at 76 characters, safely below the 998-character line limit of email (RFC 5322). 76 is a multiple of 4, so each line holds exactly 57 bytes.

Is MIME Base64 different from normal Base64?

The alphabet and padding are identical. The only difference is the line breaks, and decoders are expected to ignore them, so wrapped and unwrapped versions decode to the same bytes.

Should I wrap Base64 in an email Subject line?

No. Headers use RFC 2047 encoded-words such as =?UTF-8?B?R3LDvMOfZQ==?=, which must not contain line breaks. Encode the subject with Line wrap set to None and keep each encoded-word at 75 characters or fewer.

Why does openssl give me 64-character lines?

openssl base64 wraps at 64, the PEM convention, while GNU base64 and most mail libraries wrap at 76. Both decode the same way; pick 64 here if you need output identical to openssl.