A single string inside a DNS TXT record can be at most 255 bytes, because its length is stored in one byte. A longer value, such as a 2048-bit DKIM public key, must be split into several quoted strings inside the same record. Receivers join the strings back together without adding spaces. Many DNS panels split for you; if yours does not, enter the value as "first part" "second part".
Check what is published with the TXT lookup. A DKIM record split into two strings (key shortened for readability):
selector1._domainkey.example.com. 3600 IN TXT (
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
"...rest of the base64 key...IDAQAB" )
Where the limit comes from
RFC 1035 §3.3 defines a character-string as a single length octet followed by that many characters, so a string is at most 255 data octets (256 with the length byte). RFC 1035 §3.3.14 defines TXT data as one or more of these strings. The limit applies to each string, not to the whole record. A TXT record can carry several strings, and the overall limit is the size of the DNS message and the record set rather than 255.
The 255 limit is a property of the wire format. Whether you must split by hand depends on the zone file or panel you use to enter the data.
How receivers join the strings
Two RFCs that use TXT for email authentication state the rule explicitly:
- RFC 7208 §3.3 (SPF): a record split into several strings “MUST be treated as if those strings are concatenated together without adding spaces”. Its example turns
"v=spf1 .... first" "second string..."into"v=spf1 .... firstsecond string...". - RFC 6376 §3.6.2.2 (DKIM): “Strings in a TXT RR MUST be concatenated together before use with no intervening whitespace.”
So a split inside a word is safe, and a space you need must be inside one of the strings. For SPF that means when you break between two mechanisms, keep the space at the end of the first string:
example.com. 3600 IN TXT "v=spf1 include:_spf.provider-one.example " "include:_spf.provider-two.example ~all"
Without the trailing space, the receiver would read ...provider-one.exampleinclude:... and the record would be invalid.
Where to split
Cut at any character position for DKIM keys, since the base64 body has no meaningful boundaries. Stay under 255 bytes per string, with 250 being a comfortable round number. For SPF, prefer splitting at a space between terms. If the SPF record is long, remember that length is not the only limit: the 10-lookup limit applies as well, covered in SPF too many lookups.
Mistakes seen in DNS panels
| Symptom | Likely cause |
|---|---|
| The checker shows the value inside extra quotation marks | You typed the quotes into a panel that adds them itself |
| DKIM check reports a missing or invalid key | The key was cut at 255 characters, or a space was pasted into the middle |
| Two strings appear separated by a space | A tool is displaying the strings separately; the receiver still joins them |
| Record exists but SPF is ignored | Two SPF TXT records at the same name |
| Panel rejects the record as too long | It expects one string; split it as the panel’s help describes |
The most common: literal quotes. In zone-file syntax, quotes delimit a string and are not part of the data. Many panels expect only the value, and add the quotes in the stored zone. If you add your own, the quotes become part of the data and "v=spf1 ..." no longer starts with v=spf1. Check your provider’s documentation to learn which kind of field you have. If the TXT lookup shows your value wrapped in a second pair of quotes, remove the ones you typed.
Smart quotes pasted from a document or chat are another cause. They look like quotes but are different characters.
Several TXT records at one name
A name may hold many TXT records at once. That is normal: site-verification tokens, SPF and others share example.com. They are separate records, each with its own strings, and they are not joined together. Only the strings inside one record are concatenated.
The problem is two records of the same protocol. RFC 7208 §3.2 says a domain name MUST NOT have multiple records that would cause an authorization check to select more than one record. Two v=spf1 TXT records produce a permanent error at the receiver. Merge them into one; see multiple SPF records. Check with the TXT lookup, which lists each record separately. The DNS lookup with type TXT shows the raw answer.
DKIM and DMARC are different: each lives at its own name (<selector>._domainkey and _dmarc), so they do not collide with the apex TXT records.
Checking the result
Query the record from a resolver and compare it with what you intended. With dig the long value appears as separate quoted strings, which is the correct on-the-wire form:
$ dig +short TXT selector1._domainkey.example.com
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..." "...IDAQAB"
If the output starts with a doubled quote or contains \", a literal quote went into the data.
FAQ
Is a 255-character limit on the whole TXT record? No. The limit is per string. A record can hold several strings, which the receiver joins. The ceiling for the whole record is set by the DNS message and the record set, not by 255, so a 2048-bit DKIM key fits when split.
Should I add a space between the split parts?
Not for DKIM; the parts are joined with no whitespace, so a space would corrupt the key. For SPF, include the space inside a string wherever the terms need separating, because nothing is added for you. A cut between include:a.example and include:b.example without a space yields one invalid term.
Can I use one very long string if my DNS host accepts it? Only if the host splits it before publishing. A string over 255 bytes cannot be encoded in DNS, so a host that accepts one must be splitting it on its own. Check the published answer with the TXT lookup rather than trusting the panel.
Sources
- RFC 1035, §3.3 character-string and §3.3.14 TXT RDATA: https://www.rfc-editor.org/rfc/rfc1035#section-3.3
- RFC 7208, §3.2 Multiple DNS Records and §3.3 Multiple Strings in a Single DNS Record: https://www.rfc-editor.org/rfc/rfc7208#section-3.3
- RFC 6376, §3.6.2.2 Resource Record Types for Key Storage: https://www.rfc-editor.org/rfc/rfc6376#section-3.6.2.2