Encode Quoted Printable

Encode text to Quoted-Printable. Free QP encoder.

Encode for

Looking for the other direction? Decode Quoted Printable

Rate this tool

How useful was this tool?

Encode Quoted Printable

Type or paste into Text, or load the Example, and the encoded result appears under Quoted-Printable as you type. Choose what you’re encoding for under Encode for:

  • A message body (RFC 2045): lines of at most 76 characters with soft line breaks.
  • A header such as Subject (RFC 2047 encoded-words, =?UTF-8?Q?...?=).

Charset sets how characters outside ASCII become bytes: UTF-8, or Windows-1252 (Latin-1) for older systems. Two options adjust the body encoding:

  • Soft line breaks at 76 characters
  • Binary: encode line breaks as =0D=0A too

A summary counts the characters, bytes, encoded bytes, soft line breaks and the longest line. What was encoded lists every character that changed and why. Copy takes the result, and Clear starts over.

Example

The Example loads text with accents, symbols, an equals sign, a trailing space and a long line:

CommandCopy
Hello, = world! Café, naïve façade, 100 € and straße. Trailing space here: 
A long line to show the soft line break at 76 characters: the quick brown fox jumps over the lazy dog again and again.

encoded as a message body in UTF-8:

Hello, =3D world! Caf=C3=A9, na=C3=AFve fa=C3=A7ade, 100 =E2=82=AC and stra=
=C3=9Fe. Trailing space here:=20
A long line to show the soft line break at 76 characters: the quick brown f=
ox jumps over the lazy dog again and again.

The summary reads 193 characters, 199 bytes: 13 encoded as =XX, 186 kept as they are, 2 soft line breaks; longest line 76 characters. What was encoded explains each change:

Character Became Why
= =3D The = sign is the escape character, so it’s always encoded.
é, ï, ç, ß =C3=A9, =C3=AF, =C3=A7, =C3=9F Outside ASCII: each byte of the character in the chosen charset.
€ =E2=82=AC Outside ASCII: three bytes in UTF-8.
space at line end =20 A space or tab at the end of a line must be encoded, or mail software would strip it.

Everything else, 186 bytes of plain ASCII, is left as it is. That’s the point of Quoted-Printable: the encoded text stays readable.

The rules

Quoted-Printable (RFC 2045) is how email sends text that isn’t plain ASCII through systems built for plain ASCII:

  • Plain ASCII stays as it is, letters, digits, spaces and most punctuation.
  • The = sign, control characters and every byte outside ASCII become =XX, with the byte written in upper-case hex.
  • Spaces and tabs at the end of a line become =20 or =09. Mail servers often strip trailing whitespace, and encoding it keeps it safe.
  • No encoded line is longer than 76 characters. A longer line is split with a soft line break: an = at the end of the line, which the decoder removes, joining the line back together. In the example, “stra=” and “=C3=9Fe” become “straße” again.
  • Line breaks you type stay line breaks. In a message, they’re sent as CRLF, the line ending email uses.

Choosing the charset

Characters outside ASCII are encoded byte by byte in the chosen charset, so the same word encodes differently:

Charset Grüße
UTF-8 Gr=C3=BC=C3=9Fe
Windows-1252 Gr=FC=DFe

The message must say which one it used, in its Content-Type header, for example text/plain; charset=UTF-8. If the header names a different charset from the one the text was encoded in, the recipient sees garbled characters such as “Grüße”. Use UTF-8 unless you’re feeding an old system that only understands Windows-1252, which can only write about 250 characters. Its € is a single byte, =80.

Encoding a Subject line

Email headers can’t contain raw non-ASCII text either, and they use a different form: encoded-words. Choose A header such as Subject and text like:

CommandCopy
Café offer for 100 €

becomes:

=?UTF-8?Q?Caf=C3=A9_offer_for_100_=E2=82=AC?=

The parts are =? charset ?Q? the encoded text ?=. Inside an encoded-word, a space is written as _, and characters such as ?, = and _ are encoded. An encoded-word can be at most 75 characters, so a long subject is split into several, one after another.

The same subject can also be written with Base64 instead of Q, as =?UTF-8?B?Q2Fmw6kgb2ZmZXIgZm9yIDEwMCDigqw=?=. The decoder reads both forms.

Encoded-words are for header text: the Subject, and the display name in From or To. The email address itself is never encoded this way.

The binary option

Normally a line break in your text is a real line ending in the message. When the content isn’t text but data, where a line break is just another byte, tick Binary: encode line breaks as =0D=0A too. Every line break is then encoded, so it comes back exactly as it was. For real binary files, though, Base64 is the usual and more compact choice.

Quoted-Printable or Base64?

Both make content safe for email. Quoted-Printable is the better choice when the text is mostly ASCII, as in English, French, German or Spanish: it stays readable and grows only a little. It’s poor for text that’s mostly outside ASCII. Each non-ASCII byte becomes three characters, so the Russian "Привет", 12 bytes in UTF-8, becomes 36 characters in Quoted-Printable but only 16 in Base64. Mail programs pick between the two automatically, and you can follow the same rule.

When you’d encode by hand

  • Writing a raw email: a test .eml file, a message sent with a command-line tool while testing a mail server, or a MIME part built in code.
  • Email templates, in a sending platform that asks for the encoded body or for an encoded Subject.
  • Debugging mail code, to compare what your program produces with what the standard says it should.

FAQ

Why does = become =3D?

Because = starts every escape in Quoted-Printable. A plain = in your text has to be escaped too, as its hex value 3D, or the decoder would read the next two characters as an escape. That’s why HTML emails viewed as raw source are full of href=3D"…".

What is a soft line break?

An = at the very end of a line. It means “this line continues on the next one”. It exists only to keep lines at 76 characters or fewer, and the decoder removes it, joining the two halves back together.

My received email shows =20 and =C3=A9. What happened?

The message wasn’t decoded. Usually its Content-Transfer-Encoding header is missing or wrong, or the text was copied out of the raw source. Paste it into Decode Quoted Printable to read it.

How do I encode Quoted-Printable in code?

  • Python: quopri.encodestring(text.encode('utf-8')) for a body, or the email package, which encodes bodies and headers for you.
  • PHP: quoted_printable_encode($text) for a body, and mb_encode_mimeheader($subject, 'UTF-8', 'Q') for a header.

Note: All processing is done client-side. We do not store or see your data.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us