TXT

On this page 7

TXT is the DNS resource record type that attaches arbitrary text strings to a domain name. Among DNS records it is the general-purpose container: the DNS itself does not interpret the content, so other protocols and services define their own formats inside it, most notably email authentication policies and domain ownership verification tokens.

The TXT type, numbered 16, was defined in the original DNS specification, RFC 1035, for descriptive information. Today the overwhelming majority of TXT data is machine-readable, and a single domain often carries several TXT records at its apex and at specially prefixed names such as _dmarc or selector._domainkey.

How a TXT record stores data

A TXT record contains one or more character strings, each limited to 255 bytes and stored with a one-byte length prefix. Longer values, such as a 2,048-bit DKIM public key, are split into several strings within the same record, and the consuming application concatenates them without separators.

A name can hold multiple TXT records at once. Resolvers return all of them together in one answer, in no guaranteed order, so each consuming protocol must identify its own record by a prefix, such as v=spf1 or v=DMARC1, and ignore the rest.

The structural limits that govern TXT data are summarized below.

PropertyValue or rulePractical consequence
Record type number16Queried as type TXT
String lengthUp to 255 bytes eachLong values must be split
Strings per recordSeveral, concatenated by the readerDNS panels may split automatically
Records per nameMultiple allowedProtocols must filter by prefix
Response sizeLarge answers may exceed UDP limitsFalls back to TCP or truncation
Structural properties of TXT records

Common uses of TXT records

Most TXT records today serve email security and service verification. Several standards place their policies in TXT because adding a new record type would have required software changes across the whole DNS ecosystem.

UseOwner nameExample prefixPurpose
SPFDomain apexv=spf1Lists servers allowed to send mail
DKIMselector._domainkeyv=DKIM1Publishes the signing public key
DMARC_dmarcv=DMARC1Sets policy and reporting for failures
MTA-STS_mta-stsv=STSv1Signals an enforced TLS policy for mail
Domain verificationApex or random labelService-specific tokenProves control to a cloud service
ACME DNS-01 challenge_acme-challengeRandom tokenProves control for a TLS certificate
Typical TXT record uses

Using underscore-prefixed names keeps protocol data away from the apex and avoids collisions. This convention is formalized for many services and is the preferred design for any new TXT-based mechanism.

TXT compared with other DNS record types

Unlike A, AAAA, MX or NS records, a TXT record has no meaning to the DNS resolution process itself. Resolvers cache and return it but never follow it, while other types direct traffic or delegate authority.

Record typeContentInterpreted by
TXTFree-form text stringsApplications and external services
A and AAAAIPv4 or IPv6 addressClients connecting to a host
MXMail server name and prioritySending mail servers
CNAMEAlias to another nameResolvers during lookup
SRV and SVCBService location and parametersProtocol-aware clients
TXT and neighboring record types

A dedicated SPF record type, number 99, once existed but was deprecated in favor of TXT, because deployment never caught up. This history illustrates why TXT remains the practical choice for new text-based policies despite its lack of structure.

Managing TXT records in practice

Administrators should treat TXT records as configuration with consequences, not as notes. A single mistyped SPF or DMARC value can send legitimate mail to spam folders, and a removed verification token can disconnect a cloud service.

TaskRecommended practiceReason
Adding a mail senderEdit the existing SPF recordOnly one SPF record is allowed
Publishing a DKIM keyUse a dated or rotated selectorAllows key rotation without downtime
Introducing DMARCStart with `p=none` and reportsReveals senders before enforcement
Verifying a serviceKeep the token while the service is usedSome services recheck periodically
Changing a policyLower the TTL beforehandShortens propagation of the change
Practical rules for frequent tasks

Querying with tools such as dig TXT example.com or nslookup -type=TXT shows exactly what resolvers see, including how long strings were split. Checking the live answer after every change is faster than waiting for delivery reports.

Limits, pitfalls and security concerns

Because TXT records are flexible, they accumulate. Large domains often carry dozens of stale verification tokens, which enlarge responses and reveal which services an organization uses.

  • Multiple SPF records: two v=spf1 records cause a permanent SPF error; merge them into one.
  • SPF lookup limit: SPF evaluation allows at most 10 DNS-querying mechanisms; nested includes exceed it quickly.
  • Broken long values: copying a DKIM key with stray quotes or spaces invalidates the signature.
  • Oversized responses: very large TXT sets push answers past common UDP sizes and depend on TCP fallback.
  • Information exposure: tokens and policies are public and reveal providers and infrastructure.

A periodic audit that removes unused tokens and documents the owner of each remaining record keeps TXT data small, accurate and less revealing.

A non-technical view

A TXT record is like a notice board attached to a domain name. Anyone can read what is pinned there, but the domain owner decides what to post.

Email systems read the board to check which servers may send mail for the domain. Online services ask owners to pin a secret code there to prove they control the domain. The board itself does nothing. Its value comes from the services that read it.

A concrete example

A mid-sized accounting firm discovers that criminals are sending invoices that appear to come from its domain. Its DNS contains only an outdated SPF record that does not list the cloud mail service the firm uses, so genuine mail also fails checks.

The administrator replaces the SPF value with one record that includes the mail provider and the invoicing platform, publishes a 2,048-bit DKIM key under a new selector and adds a DMARC record with p=none and an address for aggregate reports.

After four weeks of reports confirm that every legitimate sender passes, the policy moves to p=quarantine and then to p=reject. Spoofed invoices stop reaching clients, and legitimate mail lands in inboxes reliably.