A TXT record, as the abbreviation implies, is a record, that contains info in human-readable form and not code. It can be set up for a domain name or a subdomain for many different purposes. Search engines, for example, have different ways of confirming you’re the owner of a particular domain and one of them is by creating a TXT record with specific text that they provide and which you will need to use as the record value. Exactly the same verification method is being employed by some analytics platforms that check the traffic to your Internet sites as well. However, in this case the content of the record will be read by a robot, but it will still be in human-readable form. A TXT record is additionally used if you activated the so-called SPF protection for your e-mails in order to prevent them from being forged. In this case, the record contains info showing that a certain electronic message is sent from a trusted and authorized mail server. You can use a TXT record for any kind of other information also, just like your company details, for instance.
To store new types of information, the experimental RFC 1464 suggests a structured format in TXT data fields. The format consists of the attribute name followed by the value of the attribute. The name and value are separated by an equals sign (=).
The general syntax is:
<owner> <class> <ttl> TXT "<attribute name>=<attribute value>"
name ttl class rr text joe IN TXT "Located in a black hole" "Likely to be eaten by a grue"
- Name: This is the host for the domain, which is actually a computer within the domain. The domain name is automatically appended to the host name. To make a record for the system www.example.com, the name value is just “www”. If the name field is left blank, it will default to be the record for the base domain. The record for the base domain is called the root record or apex record.
- Value: This can be free form text data of any type. Each word is treated as a separate string unless one or more strings are enclosed in quotes. The maximum length of a string is 255 bytes, but any number of strings can be present in each record. With a total limit of 65535 bytes (which is actually less)
- TTL: The TTL (Time to Live) is the amount of time the record will stay in cache on systems requesting your record (resolving nameservers, browsers, etc.). The TTL is set in seconds (e.g., 60 is one minute, 1800 is 30 minutes).
Attribute name matching rules
The attribute name is considered case-insensitive.
During lookups, TXT records that do not contain an unquoted “=” are ignored. TXT records that seem to contain a null attribute name, that is, the TXT-DATA starts with the character “=”, are also ignored.
Leading and trailing whitespace (spaces and tabs) in the attribute name are ignored unless they are quoted with a backtick (`).
Note that most DNS server implementations require a backslash (\) or double quote (“) in a text string to be quoted with a preceding backslash. The backtick (`) was chosen as a quoting character in this syntax to avoid confusion with backslash (\) (and remove the need for confusing strings that include sequences like “\\\\”).
All printable ASCII characters are permitted in the attribute value. No characters need to be quoted with a backtick (`). In other words, the first unquoted equals sign in the TXT record is the name/value delimiter. All subsequent characters are part of the value.