RFC 2047 Encoded-Word Encoder for Email Headers – Free

Turn a header value with accents, CJK text or symbols into RFC 2047 encoded words that mail servers accept. This RFC 2047 encoder outputs UTF-8 with Base64 and folds long values for you.

How to use the RFC 2047 encoder tool

  1. Type or paste the header text, without the header name, into Header value. It must be a single line.
  2. Select Encode header. The Example button encodes a sample containing accented and Japanese characters.
  3. Read the encoded words in the Result box. Long values are split over several lines, and each continuation line begins with a space.
  4. Select Copy and place the text after the header name, such as Subject:, in your message.

Why email headers need RFC 2047

The original Internet message format allows only ASCII in header fields. RFC 2047 works around that with the encoded word, a token that names a character set and an encoding and carries the text in ASCII form. Mail clients decode it for display.

An encoded word has the shape =?charset?encoding?text?=. The encoding is B for Base64 or Q for a variant of quoted-printable. This tool always writes UTF-8 with B, which current mail clients understand and which behaves predictably for any script.

RFC 2047 encoder examples

The first sample is 19 bytes in UTF-8: each é takes two bytes, the dash three and each kanji three. Those bytes are Base64 encoded and wrapped in the markers. The second sample is 67 bytes, too long for one word, so the tool emits a word for the first 45 bytes and a second word on a line that starts with a space.

Résumé — 東京
=?UTF-8?B?UsOpc3Vtw6kg4oCUIOadseS6rA==?=

Quarterly report: Zürich office résumé and café expenses for Q3
=?UTF-8?B?UXVhcnRlcmx5IHJlcG9ydDogWsO8cmljaCBvZmZpY2UgcsOpc3Vtw6kgYW5k?=
 =?UTF-8?B?IGNhZsOpIGV4cGVuc2VzIGZvciBRMw==?=

How long values are folded

An encoded word may be at most 75 characters long, and a multi-byte character must not be split between two words. The tool collects whole characters until the next one would push the chunk past 45 bytes, then starts a new word. Forty-five bytes make 60 Base64 characters, and with the 12 characters of markers each word is at most 72 characters.

The words are joined with a line break followed by a space, which is the folding syntax of email headers. Receiving clients ignore whitespace between adjacent encoded words, so the pieces are displayed as one continuous string.

RFC 2047 also limits a header line that contains encoded words to 76 characters. A full-length first word on the same line as a header name such as Subject: can exceed that. To stay strict, fold after the header name so the first word starts on a continuation line.

What to encode, and what to leave alone

The tool encodes the whole value you enter, including plain ASCII. That is correct for unstructured headers but not for every part of a structured one.

  • Subject and Comments: encode the entire text.
  • From, To, Cc and Reply-To: encode only the display name. The address inside angle brackets must stay as plain ASCII.
  • File names and other MIME parameters: the standard syntax for these is RFC 2231, not encoded words.
  • Line breaks: remove them first. Input with a line break is refused with the message Enter one email header value without line breaks.
  • Pure ASCII values: no encoding is needed.

Frequently asked questions

What does =?UTF-8?B? mean in an email subject?

It marks the start of an RFC 2047 encoded word. UTF-8 is the character set of the original text, B says the text is Base64 encoded, and the word ends at ?=. Mail clients decode it before showing the subject.

What is the difference between B and Q encoding?

B is Base64 and suits any text. Q resembles quoted-printable: ASCII letters stay readable, other bytes become =XX and spaces become underscores. Q is more legible for mostly-ASCII subjects. This tool produces B only.

Can this tool decode an encoded subject line?

No, it only encodes. To read a B-encoded word by hand, take the text between the third question mark and the closing ?= and run it through a Base64 to text decoder.

Do I still need this with SMTPUTF8?

Often yes. RFC 6532 allows raw UTF-8 in headers, but only when the servers on the path support the SMTPUTF8 extension. Encoded words work with all mail systems, so senders still use them by default.

Is the header text sent anywhere?

No. The value is converted to UTF-8 and Base64 by script in your browser. Subjects and names you enter are not transmitted.

Related tools