Table of Contents
Purpose of TXT Records
TXT records allow a domain owner to attach free form text to a domain name. Originally they were meant for human readable notes, but today they are mainly used for machine readable data that other systems can verify or use.
A TXT record belongs to a specific DNS name, for example example.com or mail.example.com, and returns one or more text strings. Applications and services know how to interpret those strings for their own purposes.
Structure of a TXT Record
A TXT record is stored in the DNS zone for a domain. Conceptually it has a name, a type, a time to live, and one or more text values. A simple representation looks like this:
| Field | Example | Meaning |
|---|---|---|
| Name | example.com. | The DNS name the record belongs to |
| Type | TXT | Indicates this is a TXT record |
| TTL | 3600 | Seconds the record can be cached |
| Data | "some text here" | The text payload returned to the client |
There can be multiple TXT records for the same name. A query for TXT example.com might return several separate text strings. Many modern uses encode structured information inside a single string so that software can parse it.
Common Uses of TXT Records
TXT records are heavily used for email and domain control purposes. Different systems define their own formats, but they all rely on the same underlying TXT mechanism.
SPF in TXT Records
Sender Policy Framework (SPF) is one of the most common uses. SPF tells the world which mail servers are allowed to send email for a domain. It is published as a specific kind of TXT record at the domain name that appears in the envelope sender of an email.
An SPF TXT record looks like this:
"v=spf1 ip4:192.0.2.10 include:_spf.provider.com -all"
Email receiving servers query DNS for a TXT record beginning with v=spf1 at the sending domain. They then use the rest of the string to decide if the sending IP is permitted.
Important rule: For a given mail sending domain, you should have only one SPF policy defined in TXT that starts with v=spf1. Multiple separate SPF TXT policies can cause mail validation problems.
DKIM in TXT Records
DomainKeys Identified Mail (DKIM) uses TXT records to publish public keys. These keys let receivers verify digital signatures that are attached to emails.
A DKIM TXT record is usually stored at a name that combines a selector with a fixed label, for example:
selector1._domainkey.example.com
The TXT value contains the DKIM version, key type, and the public key itself, for example:
"v=DKIM1; k=rsa; p=MIIBIjANBgkq..."
Mail servers that validate DKIM look up this exact TXT record to get the public key and verify that the message was signed by a server authorized by the domain owner.
DMARC in TXT Records
Domain based Message Authentication, Reporting and Conformance (DMARC) builds on SPF and DKIM and also uses a TXT record. The DMARC record is stored at a fixed subdomain under the main domain, typically:
_dmarc.example.com
A DMARC TXT value might look like:
"v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@example.com"
DMARC aware receivers check for this TXT record to decide how to handle messages that fail SPF or DKIM validation and where to send aggregate or failure reports.
Domain Verification TXT Records
Many cloud providers, certificate authorities, and third party services use TXT records to verify that you control a domain. They generate a random token and ask you to publish it as a TXT record at a specific name.
Examples include:
- Verifying ownership for a web service or cloud account. The service asks you to add TXT at
example.comor a custom label such as_service.example.comwith a specific value. - DNS based validation when issuing a TLS certificate. The certificate authority asks you to add a TXT record at a special name such as
_acme-challenge.example.com.
Once the TXT record appears in DNS with the correct value, the provider reads it, confirms control of the domain, and completes the verification process.
Other Custom Uses
Because TXT values can hold arbitrary text, many systems define their own formats inside TXT records. Some examples are:
- Anti spam and anti phishing products that add policy or configuration data.
- Site verification tokens for search engines.
- Application specific configuration hints that clients or agents read from DNS.
In each case, the structure of the text inside the TXT record is defined by the application that uses it, not by DNS itself.
TXT Records and DNS Queries
From the DNS server perspective, TXT records are just another resource record type. A client that wants TXT data sends a query with type TXT for a given name and receives one or more text strings in the answer.
TXT records can be cached according to their TTL. This helps reduce repeated lookups but also means that changes to TXT values, such as SPF or DMARC updates, might not be visible immediately everywhere.
TXT records are not used for actual name to IP address resolution, but they are often consulted during related operations such as processing incoming email or checking domain ownership.