Skip to main content

2. Format of TXT record

To store new types of information, the TXT record uses a structured format in its TXT-DATA field. The format consists of the attribute name followed by the value of the attribute. The name and value are separated by an equals sign (=).

For example, the following TXT records contain attributes specified in this fashion:

host.widgets.com   IN   TXT   "printer=lpr5"
sam.widgets.com IN TXT "favorite drink=orange juice"

The general syntax is:

<owner> <class> <ttl> TXT "<attribute name>=<attribute value>"

2.1. Attribute Names​

Any printable ASCII character is permitted for the attribute name. If an equals sign is embedded in the attribute name, it must be quoted with a preceding grave accent (or backquote: ""). A backquote must also be quoted with an additional "".

2.2. Attribute Name Matching Rules​

The attribute name is considered case-insensitive. For example, a lookup of the attribute "Favorite Drink" would match a TXT record containing "favorite drink=Earl Grey tea".

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 ""). For example, "abc" matches " abc<tab>" but does not match " abc".

Note that most DNS server implementations require a backslash () or double quote (") in a text string to be quoted with a preceding backslash. Accent grave ("`") was chosen as a quoting character in this syntax to avoid confusion with "" (and remove the need for confusing strings that include sequences like "\\").

2.3. Attribute Values​

All printable ASCII characters are permitted in the attribute value. No characters need to be quoted with a "`". 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.

Once again, note that in most implementations the backslash character is an active quoting character (and must, itself, be quoted).

All whitespace in the attribute value is returned to the requestor (it is up to the application to decide if it is significant.)

2.4. Examples​

indicates a space character.

Attribute    Attribute       Internal Form           External Form
Name Value (server to resolver) (TXT record)

color blue color=blue "color=blue"
equation a=4 equation=a=4 "equation=a=4"
a=a true a`=a=true "a`=a=true"
a\=a false a\`=a=false "a\\`=a=false"
= \= `==\= "`==\\="

string "Cat" string="Cat" "string=\"Cat\""
string2 `abc` string2=``abc`` "string2=``abc``"
novalue novalue= "novalue="
a b c d a b=c d "a b=c d"
abc<sp> 123<sp> abc` =123<sp> "abc` =123 "