How to use the dns txt record splitter
- Choose Split into strings, then paste the whole TXT value, such as a DKIM record, in the box.
- Choose the longest string. 255 bytes is the most that one string can hold.
- Choose one line or one string per line, and tick Remove line breaks if the value was copied across several lines.
- Copy the quoted strings. To go the other way, choose Join strings and paste the quoted strings.
Formula
Each string is at most 255 bytes (a one-byte length followed by the text)
A quote inside a string is written \" and a backslash is written \\
The record value is all strings joined end to end with nothing between them
Characters outside ASCII take more than one byte, and a character is never cut in two.
A 282 byte DKIM style value
The sample value starts with v=DKIM1; k=rsa; p= and continues with a long run of base64 text, 282 bytes in all. At 255 bytes it becomes two strings, the first with 255 bytes and the second with the remaining 27 bytes, written as "first string" "second string".
With a longest string of 128 bytes the same value becomes three strings of 128, 128 and 26 bytes, and with One string per line each is on its own line. Pasting those strings back with Join strings gives the 282 byte value again.
Why a record needs splitting
Inside a DNS message, each string in a TXT record is stored with a length in a single byte, so no string can be longer than 255 bytes. A 2048-bit DKIM key written in base64 is about 400 characters, so it has to be stored as two strings. A resolver joins the strings back together without adding spaces, which is why the pieces must be cut exactly at the point where one ends and the next begins.
Some DNS hosts accept the whole value and split it for you. Others reject a value over 255 characters, and some want the quoted strings typed in. Check the help pages of your host, and look at the record with a lookup tool after you save it.
Quotes, escapes and spaces
A quote or a backslash inside a string must be escaped, and the tool does it for you. A space between two quoted strings is only a separator in the zone file and is not part of the value, so a key split across two strings has no space in the middle. If your value has a space that matters, such as the one after the semicolon in v=DKIM1; k=rsa, it stays inside the string where you put it.
See also the SPF Record Parser, the DMARC Record Builder and Parser, the Base64 Encoder and Decoder for the key text and the Quoted-Printable Encoder and Decoder for another email encoding.
Assumptions and limits
- The limit of 255 bytes is for one string. The whole record can be longer, up to the size of a DNS message.
- Non-ASCII characters are kept as typed. Many DNS hosts expect plain ASCII.
- The sample key is made up and is not a working key.
- Line breaks are removed from the value only when the box is ticked.
Frequently asked questions
Do I need quotes in my DNS panel?
It depends on the host. Some add the quotes themselves and some want them typed. Try the quoted form first and look at the saved record to see.
Why 255 and not 256?
The length is stored in one byte, which holds 0 to 255, so 255 is the largest length that fits.
Does splitting change the value?
No, as long as the pieces are joined end to end with no added characters. Joining the strings returns the original value.
Can I split into shorter pieces?
Yes. Choose 200 or 128 bytes. Shorter pieces are accepted everywhere that accepts the longer ones.