DevToys Pro

free web developer tools

Blog
Rate us:
Try browser extension:
← Back to Blog

Quoted-Printable: Email Encoding Explained

12 min read

If you have ever inspected the raw source of an email message and seen sequences like =3D, =20, or mysterious =\r\n line breaks, you were looking at Quoted-Printable encoding. This MIME encoding format is designed to keep email content mostly human-readable while safely transmitting special characters through email systems that were historically limited to 7-bit ASCII.

This guide explains what Quoted-Printable encoding is, how it works, when to use it instead of Base64, and how to debug email encoding issues using a Quoted-Printable encoder/decoder.

What Is Quoted-Printable Encoding?

Quoted-Printable (often abbreviated as QP encoding) is one of two primary content transfer encodings defined in the MIME standard (the other being Base64). It was created to encode email content that is mostly plain ASCII text with occasional non-ASCII characters or special symbols.

The key characteristics of Quoted-Printable encoding:

  • ASCII characters (33-126, excluding =) are left unchanged
  • Spaces and tabs can remain as-is in most contexts
  • Non-ASCII and special characters are encoded as =XX where XX is the hexadecimal byte value
  • Lines must not exceed 76 characters, enforced with soft line breaks (= at end of line)
  • Mostly human-readable when content is primarily ASCII text

Encoding Rules

Rule 1: Encode Non-Printable and Special Characters

Any byte that is not a printable ASCII character (or is the equals sign itself) must be encoded as =XX:

CharacterByte Value (Hex)Quoted-Printable
=0x3D=3D
Space at line end0x20=20
Tab at line end0x09=09
Non-ASCII (é)0xC3 0xA9 (UTF-8)=C3=A9

Rule 2: Soft Line Breaks

Lines longer than 76 characters must be split using a soft line break: an equals sign followed by a CRLF (=\r\n). This tells the decoder that the line continues on the next line and the equals sign should be removed during decoding.

This is a very long line of text that exceeds the 76 character limit and=
 must be split using a soft line break to comply with MIME standards.

// Decodes to:
This is a very long line of text that exceeds the 76 character limit and must be split using a soft line break to comply with MIME standards.

Important: The space after = on the continuation line is part of the original content, not added by the encoding. If there was no space originally, the continuation starts immediately with no leading space.

Rule 3: Whitespace at Line End

Spaces and tabs at the end of a line must be encoded because some email systems strip trailing whitespace:

// Original: "Hello world  " (two trailing spaces)
// Encoded: "Hello world=20=20"

// This prevents email systems from removing the trailing spaces

Real Email Example

Here is what a real MIME email message header and body look like with QP encoding:

From: sender@example.com
To: recipient@example.com
Subject: =?UTF-8?Q?Test:_Special_Characters_=C3=A9=C3=B1?=
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello,

This email contains special characters: =C3=A9 (é), =C3=B1).
Equals signs must be encoded: 2 + 2 =3D 4

Long lines are wrapped with soft breaks:
This is a very long line that goes beyond seventy-six characters and nee=
ds to be split.

Best regards

Notice that the Subject header also uses a form of Quoted-Printable encoding (called "Q-encoding" or "RFC 2047 encoding") but with a different syntax: =?charset?Q?encoded_text?=. Underscores represent spaces in header encoding.

Quoted-Printable vs Base64

MIME defines two main content transfer encodings. Choosing between Quoted-Printable and Base64 depends on the type of content:

AspectQuoted-PrintableBase64
Best forMostly ASCII text with few non-ASCII charactersBinary data, images, non-text files
ReadabilityHuman-readable for ASCII portionsCompletely encoded, not human-readable
OverheadLow if content is mostly ASCII (~1-3% for English)Fixed 33% overhead regardless of content
Line length76 characters, soft line breaks76 characters, hard line breaks
Use caseEmail body text, HTML emailsAttachments, images, PDF files

When to Use Quoted-Printable

Choose Quoted-Printable when:

  • Content is primarily plain text or HTML
  • Most characters are standard ASCII (A-Z, a-z, 0-9, common punctuation)
  • Only occasional accented characters, emoji, or symbols appear
  • You want the content to remain mostly human-readable in raw source
  • Email body content in languages using Latin-based scripts

When to Use Base64

Choose Base64 when:

  • Content is binary data (images, PDF, ZIP files)
  • More than ~30% of bytes are non-ASCII
  • Content uses non-Latin scripts extensively (Chinese, Arabic, Cyrillic)
  • Attachments of any file type

For a Base64 encoder/decoder, see the DevToys Pro Base64 Tool.

Common Use Cases

Case 1: Plain Text Email with Accented Characters

Original message:
"Café résumé naïve"

Quoted-Printable encoded:
"Caf=C3=A9 r=C3=A9sum=C3=A9 na=C3=AFve"

// Only non-ASCII characters are encoded
// English words remain readable

Case 2: HTML Email Body

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
<body>
<p>Welcome to our newsletter!</p>
<p>Special offer: 50=25 off</p>
<p>Location: Caf=C3=A9 &#201;toile</p>
</body>
</html>

// % encoded as =25 (0x25 in hex)
// é encoded as =C3=A9 (UTF-8 bytes)

Case 3: Email with Long URLs

Original:
"Visit our website: https://example.com/products?category=electronics&sort=price&filter=new"

Quoted-Printable encoded:
"Visit our website: https://example.com/products?category=3Delectronics&s=
ort=3Dprice&filter=3Dnew"

// Notice:
// 1. = encoded as =3D
// 2. Soft line break (=) splits long line
// 3. & stays as-is (printable ASCII)

Debugging Email Encoding Issues

Issue 1: Equals Signs Appear in Email Text

If your email displays literal =3D, =20, or other =XX sequences, the email client failed to decode Quoted-Printable encoding.

Common causes:

  • Missing or incorrect Content-Transfer-Encoding: quoted-printable header
  • Email client does not support Quoted-Printable
  • Email was forwarded and re-encoded incorrectly

Fix: Ensure the MIME headers correctly declare the encoding. Use a Quoted-Printable decoder to manually decode and verify the content.

Issue 2: Line Breaks Appear in Wrong Places

If you see unexpected line breaks in words, the email was likely encoded with hard line breaks instead of soft line breaks:

// Wrong: hard line break (no =)
This is a long line that wraps
here without soft break marker

// Displays as two lines with break in middle of sentence

// Correct: soft line break (=)
This is a long line that wraps=
 here with soft break marker

// Displays as one continuous line

Issue 3: Trailing Spaces Lost

If spaces at the end of lines disappear, they were not encoded. Email systems often strip trailing whitespace from plain text. If preserving trailing spaces is critical, they must be encoded as =20 or =09 (tab).

Encoding and Decoding Quoted-Printable

Manual Encoding Algorithm

To encode text as Quoted-Printable:

  1. For each byte in the input:
    • If printable ASCII (33-60, 62-126): output as-is (except = → encode as =3D)
    • If space or tab: output as-is unless at end of line (then encode as =20 or =09)
    • Otherwise: encode as =XX (hex byte value)
  2. If line exceeds 76 characters, insert =\r\n soft line break
  3. Ensure lines end with CRLF (\r\n)

Manual Decoding Algorithm

To decode Quoted-Printable text:

  1. For each character in the input:
    • If =XX: convert hex XX to byte value
    • If =\r\n (soft line break): skip, continue on next line
    • Otherwise: output character as-is
  2. Reconstruct multi-byte UTF-8 sequences from decoded bytes

Using a Quoted-Printable Tool

For practical encoding and decoding, use a dedicated Quoted-Printable encoder/decoder. With the DevToys Pro Quoted-Printable Tool you can:

  • Encode plain text or HTML for email transmission
  • Decode Quoted-Printable email bodies to verify content
  • Test how special characters are encoded
  • Debug email rendering issues by decoding raw source
  • Verify soft line breaks are inserted correctly

MIME Header Encoding (Q-Encoding)

Email headers (Subject, From, To) use a variant called Q-encoding or RFC 2047 encoding. It follows similar rules but uses a different wrapper syntax:

Subject: =?UTF-8?Q?Caf=C3=A9_R=C3=A9sum=C3=A9?=

// Format: =?charset?Q?encoded_text?=
// _ represents space in headers
// Same hex encoding as Quoted-Printable body

Key differences from body Quoted-Printable:

  • Spaces encoded as underscore (_) instead of =20
  • Wrapped in =?charset?Q?...?= delimiters
  • Used exclusively in headers, not message body
  • Limited to 75 characters per encoded-word

Best Practices

1. Choose the Right Encoding

Use Quoted-Printable for text content, Base64 for binary attachments. Do not use Quoted-Printable for images or files—they will bloat significantly.

2. Set Correct MIME Headers

Always declare the encoding in the MIME headers:

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

// Both headers are required for proper decoding

3. Use Soft Line Breaks Correctly

Ensure soft line breaks are inserted before the 76-character limit and use proper CRLF line endings (\r\n, not just \n).

4. Test with Multiple Clients

Test encoded emails in multiple email clients (Gmail, Outlook, Apple Mail, Thunderbird) to verify decoding works correctly across platforms.

5. Use Libraries for Production

For production email sending, use established libraries that handle MIME encoding automatically:

// Python
from email.mime.text import MIMEText
msg = MIMEText("Café", 'plain', 'utf-8')
# Automatically applies Quoted-Printable if appropriate

// Node.js (Nodemailer)
const mailOptions = {
  text: 'Café',
  encoding: 'quoted-printable'
};

Quick Reference

PatternMeaningExample
=XXEncoded byte (hex)=3D is =
=\r\nSoft line break (ignored by decoder)Splits long lines
=20Space (at line end)Preserves trailing space
=09Tab (at line end)Preserves trailing tab
76 chars maxLine length limitInsert soft breaks before limit
=?charset?Q?text?=Header encoding (Q-encoding)=?UTF-8?Q?Caf=C3=A9?=

Conclusion

Quoted-Printable encoding is an elegant solution for email transmission that keeps mostly ASCII text human-readable while safely encoding non-ASCII characters and special symbols. Understanding when to use Quoted-Printable versus Base64, how soft line breaks work, and how to debug encoding issues will help you build reliable email systems and troubleshoot rendering problems.

Key takeaways:

  • Quoted-Printable keeps ASCII text readable, encodes non-ASCII as =XX
  • Soft line breaks (=\r\n) split long lines without affecting decoded output
  • Use QP for text, Base64 for binary data and attachments
  • Email headers use Q-encoding variant with underscores for spaces
  • Always set MIME headers correctly for proper client decoding

For testing and debugging email encoding, use a Quoted-Printable encoder/decoder to encode content before sending or decode raw email source to verify how special characters and line breaks are handled.