TXT record
Learn what a DNS TXT record is, its versatile uses for email authentication (SPF, DKIM, DMARC), domain verification, common formats, lookup methods, and best practices to avoid common pitfalls.
What Is a TXT Record in DNS?
TL;DR
A TXT record stores arbitrary text strings associated with a domain name.
It's one of the most flexible DNS types and is widely used for:
- Email authentication (SPF, DKIM, DMARC)
- Domain ownership verification (Google, Microsoft, SSL providers)
- Custom configuration or notes
TXT values are quoted strings (up to 255 chars each); multiple strings concatenate automatically.
How TXT Records Work
When queried, all TXT records for a name are returned.
Resolvers concatenate multiple strings into one value (no extra spaces added).
TXT is "unstructured" applications interpret the content (e.g., SPF parsers look for v=spf1).
Common Use Cases
- Email authentication: SPF (authorized senders), DKIM (signatures), DMARC (policy & reporting)
- Domain verification: proving ownership to Google Workspace, Microsoft 365, Let's Encrypt, AWS, etc.
- Site verification: Google Search Console, Bing Webmaster Tools
- Custom data: application configs, security policies, human-readable notes
- Wildcard TXT: apply verification to all subdomains (rare)
How to Lookup TXT Records
dig example.com TXTnslookup -type=TXT example.comRecord Format
NAME TTL CLASS TYPE VALUE
example.com. 3600 IN TXT "v=spf1 include:_spf.google.com ~all"- Values in quotes if they contain spaces
- Multiple quoted strings allowed (concatenated)
- No limit on number of TXT records per name
Valid Examples
Basic SPF
example.com. TXT "v=spf1 include:_spf.google.com ~all"Long SPF (split strings)
example.com. TXT "v=spf1 include:_spf.google.com include:mailgun.org" "include:sendgrid.net ~all"DMARC policy
example.com. TXT "v=DMARC1; p=quarantine; pct=100; rua=mailto:[email protected]"Domain verification
example.com. TXT "google-site-verification=ABC123XYZ789abcdef"DKIM public key (selector-based)
selector._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD..."TXT vs Other Record Types
| Feature | TXT | A / AAAA | MX |
|---|---|---|---|
| Purpose | Arbitrary text / config | IP address mapping | Mail server routing |
| Email auth support | Yes (SPF/DKIM/DMARC) | No | Yes (delivery) |
| Multiple allowed | Yes | Yes | Yes |
| Root domain | Yes | Yes | Yes |
| Structured parsing | Application-specific | No | Priority-based |
→ See also: MX Record, A Record
Frequently Asked Questions
What's the max length of a TXT record?
Why do email providers need TXT records?
Can I have multiple TXT records?
How do I know which TXT records to add?
References
Related: MX Record · A Record · DNS Basics