What Is a DNS TXT Record?

Most DNS records contain data only for machines. However, TXT records - also known as text records - are multi-purpose records that include both human- and computer-readable instructions. Many domain administrators use this record for purposes such as email validation, ownership verification, and framework policies. In this article, learn everything you need to know about the DNS TXT record.

What is TXT record?

A TXT record is a text DNS record with text-format data for external sources. This type of record stores general information about a domain, like contact details, in a format that's easy for people to understand. However, TXT records can also hold messages in a format computers can understand, making them incredibly useful.

In the early days of the domain name system (DNS), which links domain names to IP addresses, administrators used TXT records simply for human-readable notes. But since computers understand text, these records have become a bridge between humans and machines. Now, administrators can enter instructions directly into the DNS through text records to give computer commands.

A text record holds a special code that is publicly available so that others can verify the domain. Website admins place this code through their DNS settings. Most third parties use this code to verify the domain owner. 

How do TXT records work?

TXT records store text data in DNS records that can be retrieved when queried. According to RFC 1035, the records were first introduced as an experimental format in 1993.

TXT records are an important part of DNS.

Basic text records don't have strict formatting requirements. The information can be free-form text if it adheres to character limits.

This type of DNS record has a limit of 255 characters per individual string within the record. If the data you want to store exceeds 255 characters, it must be split into multiple quoted strings.

Each section is then enclosed in double quotes. This flexibility allows the record to remain readable by DNS servers despite being broken down into parts.

Structure of the TXT record

The format of a TXT record is simple, with the text entry often encapsulating data in an attribute-value pair format. It features the following fields:

Hostname Record type Value TTL
example.comTXTv=spf1 include:example.com ~all32600
  • Host specifies the hostname or subdomain to which the text record applies. For example, a record for your entire domain might use "@," while a record for a specific subdomain like "[invalid URL removed]" would use use "mail."
  • Record type indicates the type of DNS record, which is "TXT" for a TXT record.
  • TTL (Time To Live) values define how long other DNS servers can cache the text record information before refreshing it with your DNS provider. A shorter TTL can be useful for records that might change frequently, while a longer TTL is beneficial for more stable records.
  • Value contains the actual text information associated with the TXT record. It could include verification codes or SPF records for email authentication, but it could also include other text-based data required for domain configuration purposes. 

What benefits do TXT records have for domain owners? 

TXT records offer many benefits to domain owners, from email security to SEO optimization. Consider the benefits of the records below.

Domain ownership verification

A TXT record is a powerful tool for verifying domain ownership. The process involves adding a specific text record to your DNS configuration, proving your domain control. Various services require these records to confirm ownership before allowing domain-related changes.

Strengthening email security

Text records enhance email security by allowing domain administrators to implement measures like Sender Policy Framework (SPF) and DomainKeys Identified Mail (DKIM). These records help verify that emails sent from a domain are legitimate - a way to mitigate email spoofing.

SPF and DMARC policies

TXT records are used to implement SPF (Sender Policy Framework) and DMARC (Domain-based Message Authentication, Reporting, and Conformance) policies. Both are essential for authenticating email sources and improving email deliverability. 

SPF records specify which mail servers are permitted to send emails on behalf of your domain. DMARC policies, on the other hand, provide instructions on how to handle emails that fail SPF or DKIM checks.

SEO optimization

While not a direct ranking factor, TXT records can support SEO through verification with Google Search Console (GSC). Verifying your website ownership with GSC grants you a verified badge in search results. 

Information dissemination

While most people consider DNS records purely technical, TXT records offer a surprising benefit: public information storage. 

You can use them to provide additional information about your company, such as email addresses, phone numbers, or social media handles. This makes it easier for users to find contact details without searching your website.

How to set up a TXT record

To successfully set up a text record, follow these steps:

  1. Log into your domain hosting control panel.
  2. Navigate to the DNS management page.
  3. Select the option to add a new record and choose TXT as the record type.
  4. Enter the appropriate details in the Host and Value fields.
  5. Set the TTL according to how often you expect to update the record.
  6. Save the changes and wait for the record to propagate across the DNS servers.

Ensure that each step is followed carefully to avoid common pitfalls.

Advanced configurations of text records

Handling large data

When dealing with text records that contain data exceeding 255 characters, it is necessary to split the data into multiple strings. Each string must be enclosed in double quotes for proper formatting and parsing by DNS servers.

Using quotes for long text

Using double quotes is essential for TXT records that hold lengthy data. The method allows for the inclusion of extended information without breaching the single string limit imposed by DNS protocols.

Multiple TXT records for a domain

A domain can support multiple text records, each serving a different purpose. Administrators use this to manage various aspects of domain verification. 

Common challenges with TXT records

Here are the main issues DNS administrators experience with TXT records.

Propagation issues

Propagation delays are common when updating or setting up new TXT records. These delays can range from a few hours, depending on the TTL set for the record. Ensure that the TTL is set appropriately to avoid prolonged delays. 

Syntax errors 

Text records are unforgiving of typos or syntax mistakes. Though a mistake may seem small, a single misplaced character can render the record ineffective. Each string within the value field has a limit of 255 characters. This can be a hurdle when dealing with longer data.

Luckily, text records allow including multiple strings to accommodate data exceeding the limit.

Overlapping records

Having multiple TXT records for the same service on your domain can confuse DNS servers. It can happen accidentally or if you're unsure about existing records before creating new ones.

Verification failures

Verification failures often occur due to incorrect text record values or premature verification attempts.

How to troubleshoot TXT record issues 

While conflicts in TXT records can arise, these are some best practices for addressing them and avoiding problems later.

  • Update your records. SPF, DKIM, and DMARC records, commonly used within text records for email security, can become outdated over time. Regularly updating them ensures continued effectiveness against evolving threats.
  • Maintain documentation. TXT records often hold cryptic data strings that might be confusing in the future. Therefore, maintaining documentation that explains the purpose of each record is vital. Clarity is key for quickly identifying, managing, and modifying records as needed. 
  • Implement DNSSEC. Implementing DNS Security Extensions (DNSSEC) is highly recommended for fortifying the security of your domain's entire DNS data, including TXT records. DNSSEC adds a layer of verification to all DNS responses. The authentication tool makes it hard for attackers to manipulate these records.
  • Limit access control. Limit access to your domain's DNS settings and zone file. Only authorized personnel who actively manage your domain should have access to make changes. Then, you can prevent unauthorized tampering with critical text records.
  • Utilize tools. Leverage online tools like TXT record validators to check your record syntax for errors before adding it to your DNS settings.

How do you query a TXT record?

Querying a text record varies depending on your operating system (OS). Below are instructions for Windows, Linux, and macOS.

Using Windows

To query a TXT record in Windows:

  1. Click on the Windows Start button or search bar and type cmd.
  2. Type the following command: nslookup -type=txt example.com. Substitute example.com with the actual domain you're interested in.
  3. Hit the Enter key to execute the command.

The command prompt will then display the results.

Using Linux

To query a TXT record in Linux:

  1. Open the Terminal application on your Linux system.
  2. Type the following command in your Terminal window: dig example.com TXT. You can replace example.com with the actual domain name you want to query.
  3. Press the Enter key to execute the command.

The Terminal window will then display the results of the query.

Using macOS

To query a TXT record in macOS:

  1. Open the Terminal application in your Mac. Find it in the Utilities folder within Applications.
  2. Like on Linux, type the following command in your Terminal window: dig example.com TXT. Replace example.com with the actual domain name you're probing.
  3. Once you've entered the command, press the Return key and execute it.

The Terminal window will then display the results of the query.

Frequently asked questions

How does a TXT record prevent email spam?

Text records help prevent email spam by allowing domain administrators to specify which email servers are authorized to send emails on behalf of a domain. 

Can a domain have multiple TXT records?

Yes, a domain can have multiple text records. Each record can serve different purposes, such as one for SPF implementation, another for DMARC configuration, and yet another for domain ownership verification.

How do I set up a TXT record for email authentication?

Create a TXT record in your DNS settings and include the necessary DMARC or DKIM values.  

Author

Written by Lizzy Schinkel & WhatIsMyIP.com® Editorial Contributors

Lizzy is a tech writer for WhatIsMyIP.com®, where she simplifies complex tech topics for readers of all levels. A Grove City College graduate with a bachelor’s degree in English, she’s been crafting clear and engaging content since 2020. When she’s not writing about IP addresses and online privacy, you’ll likely find her with a good book or exploring the latest tech trends.

Reviewer

Technically Reviewed by Brian Gilbert

Brian Gilbert is a tech enthusiast, network engineer, and lifelong problem solver with a knack for making complicated topics simple. As the overseer of WhatIsMyIP.com®, he combines decades of experience with a passion for helping others navigate the digital world.