Q-encoding header encoder
Put accents into an email Subject or sender name safely: Hello café becomes =?UTF-8?Q?Hello_caf=C3=A9?=, and a pasted encoded-word decodes back to readable text. Spaces turn into underscores and broken escapes are refused. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Text
- Hello café
- Calculation mode
- Encode
- Result
- =?UTF-8?Q?Hello_caf=C3=A9?=
- Encoding
- rfc2047-q
- Charset
- UTF-8
- Form
- Encoded word
This Q-encoding header encoder converts plain UTF-8 text into the RFC 2047 Q form used inside MIME encoded-words for non-ASCII email headers, and decodes those strings back to readable text. charset? Q? …? The engine is fully deterministic: the same input, mode, charset, and form always produce the same result, with no network calls, no random salts, and no date-dependent shortcuts. Common checks include encoding Hello café to =? UTF-8? Q? Hello_caf=C3=A9? = and decoding that string back to the original phrase.
What RFC 2047 Q-encoding is and what this tool returns
RFC 2047 defines encoded-words so email headers that historically expected mostly ASCII can still carry international text without breaking SMTP path rules. The Q method keeps mostly Latin text readable on a dumb terminal: safe printable ASCII appears as itself, the space character is preferably written as an underscore, and any other octet becomes an equals sign followed by two uppercase hexadecimal digits. The equals sign, question mark, and underscore themselves must be escaped when they appear as data, because they are structural inside the encoded-word grammar.
Soft line breaks from body quoted-printable do not apply here: an encoded-word is a single atomic token and must not contain a soft-break sequence. If you need opaque binary packing for headers, prefer the B method or a Base64 helper; this landing is for the readable Q path that subjects and display names still use every day.
Where Q-encoding shows up in email headers
Developers meet RFC 2047 Q-encoding when they inspect Subject lines that begin with equals-question UTF-8 question Q, craft international display names for From and To headers, or debug why a café accent turned into underscore and equals-hex pairs in a raw message dump. Frontend and support teams decode Q snippets during ticket investigation without pasting data into ad-hoc scripts that mishandle underscore-for-space or confuse body quoted-printable with header Q rules.
Backend services encode configuration samples or short multilingual strings before putting them in header fields where unrestricted 8-bit transport is not guaranteed. Quality engineers generate deterministic encode and decode pairs for contract tests so a mail library that claims RFC 2047 support cannot silently change hex casing, leave spaces unescaped, or accept broken equals sequences. Educators use the same tool when teaching the difference between body quoted-printable soft breaks and header Q atoms that must stay on one token.
Pair it with MIME quoted-printable helpers when you are working on bodies rather than headers, and with Base64 helpers when a B-encoded-word is the right choice for dense binary-looking header data.
What you can do with it
Subject and display-name debugging
Encode or decode RFC 2047 Q-encoded Subject and From display-name fragments so accents and spaces match what mail clients show.
Legacy gateway header prep
Turn UTF-8 plain text into transport-safe Q-encoded header tokens before sending through restricted 7-bit mail paths.
FAQ
What does the Q-encoding header encoder cost?
It is free in your browser on this page.
How is header Q-encoding different from body quoted-printable?
Header Q-encoding (RFC 2047) maps space to underscore, forbids soft line breaks inside an encoded-word, and treats =, ?, and _ as special.
Is the result deterministic?
Yes. The same text, mode, charset, and form always produce the same result with no network, randomness, or date-dependent behavior.
Why are spaces written as underscores in a Q-encoded header?
An encoded-word has to stay one unbroken token inside the header, so the Q method writes each space as an underscore. When you decode, every underscore turns back into a space, and a real underscore in your text is escaped instead.
Should I use Q or B encoding for an email header?
Use Q when the text is mostly Latin letters, because it stays readable in a raw message. B, based on Base64, suits dense data that would be almost all escapes in Q. This tool handles the readable Q form only.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/enc/quoted-printable-q \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Hello café"}'const res = await fetch("https://api.kit.forhosting.com/enc/quoted-printable-q", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "Hello café"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/enc/quoted-printable-q",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "Hello café"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/enc/quoted-printable-q", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"Hello café"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"Hello café"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/enc/quoted-printable-q", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "Hello café"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "enc.quoted_printable_q",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Unlike body quoted-printable, header Q-encoding maps every space to an underscore, forbids soft line breaks inside an encoded-word, and reserves the question mark and underscore so mail parsers never confuse the payload with the =? Use it free in the browser for mail debugging and header practice, or call the API at $0.002 per successful request when pipelines need reproducible RFC 2047 transforms in CI and backend services.
What RFC 2047 Q-encoding is and what this tool returns
An encoded-word looks like equals-question charset question encoding question payload question-equals, where the encoding letter is Q for the quoted-printable-like method or B for Base64. This page always follows that contract for UTF-8 text by default: encode mode maps your string to charset bytes, emits underscore for space and equals-hex for unsafe bytes, then optionally wraps the payload as a full encoded-word; decode mode accepts either a full encoded-word or a bare Q payload, expands underscore and equals-hex pairs, and rejects incomplete or non-hex escape sequences instead of guessing. The JSON response includes result for the transformed string, mode echoing encode or decode, encoding fixed to rfc2047-q, charset, form (encoded_word or payload), the bare payload field for easy assertions, and input_bytes plus output_bytes so you can pin sizes in tests. There is no streaming path and no silent repair of broken Q text: either the string is valid or the request fails with invalid_input.
How text, mode, charset, and form are read and how results stay reproducible
charset? Q? …? Encode accepts Unicode strings, converts them with the chosen charset rules, then emits Q tokens with uppercase hex escapes and underscore for every space. After bytes are recovered, a fatal UTF-8 decode ensures binary garbage does not become mojibake when the charset is UTF-8. The preferred payload field is text, with aliases input, value, and s so forms, query strings, and SDK clients can reuse the same contract without renaming columns. Mode defaults to encode and accepts decode explicitly; aliases op, direction, and action map to the same switch for scripts that already use those names. Charset defaults to UTF-8 and is written into the encoded-word on encode; when decoding a full encoded-word the charset is taken from the token itself, and when decoding a bare payload the charset parameter selects how recovered bytes become text. Form defaults to encoded_word so encode returns a complete =? Decode requires a well-formed Q string: a lone equals at the end of input, an equals followed by one character only, or an equals followed by non-hex digits all fail with a clear invalid_input message naming the malformed escape. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing RFC 2047 tables yourself. Invalid inputs return invalid_input and are not charged, which keeps validation cheap while successful transforms remain a fixed item price of $0.002.
Where Q-encoding fits in email headers, MIME, and test fixtures
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the encoded result.
Integration use cases
Mail header fixture generation
Produce reproducible encoded-words for unit tests, golden files, and SMTP or IMAP integration checks that assert header form.
Technical questions
What modes and forms are supported?
mode=encode (default) turns plain text into Q-encoding; mode=decode turns a Q string back into text. form=encoded_word (default on encode) wraps as =?charset?Q?payload?=; form=payload returns only the inner Q body.
What happens if an escape sequence is malformed?
Decode fails with invalid_input. Incomplete =XX, non-hex digits after =, or illegal characters in a Q payload are all rejected rather than guessed.