Domain names look simple, but they follow precise technical rules defined in internet standards, with additional policies set by each registry. Knowing these rules helps when choosing a name, validating input in software or understanding why a registrar rejects a request.
Labels and the full name
A domain name is a sequence of labels separated by dots. In blog.example.com, the labels are blog, example and com. The rightmost label is the top-level domain (TLD), the next is usually the registered name, and anything to the left is a subdomain controlled by the domain owner.
Length limits
- Each label: 1 to 63 octets. In ordinary ASCII names, that means up to 63 characters per label.
- The full name: at most 255 octets in the DNS wire format, which corresponds to a maximum of 253 characters when written in the usual dotted text form without a trailing dot.
Registries may impose stricter limits for the registered label, and some require a minimum length, for example rejecting very short names or reserving them. Check the policy of the specific TLD.
Allowed characters: the LDH rule
Host names traditionally follow the "letters, digits, hyphen" (LDH) rule:
- ASCII letters
a–z(case-insensitive, soExample.comandexample.comare the same); - digits
0–9; - the hyphen
-.
Spaces, underscores, punctuation and symbols are not allowed in registered host names. A label can start with a digit; names made entirely of digits are allowed in principle, although some registries restrict them.
Hyphen rules
A label may not start or end with a hyphen. Hyphens in the third and fourth positions together, as in ab--cd, are reserved: the prefix xn-- marks internationalized labels, and registries generally refuse other names with hyphens in those positions.
Internationalized domain names
Names containing non-ASCII characters, such as accented letters or other scripts, are supported through the IDNA standards. Such labels are converted to an ASCII form called Punycode with the xn-- prefix, and the length limits apply to that encoded form. A label that looks short in its native script can become long when encoded. Registries decide which scripts and characters they accept and often have rules to prevent confusable look-alike names.
Underscores in DNS records
You will see underscores in some DNS names, such as _dmarc.example.com or service records like _sip._tcp.example.com. These are not host names; DNS itself allows a wider range of characters in record names, and certain protocols use underscore-prefixed labels by convention. You cannot register a domain with an underscore.
Case and trailing dots
DNS compares names without regard to ASCII letter case, and registries store them in lowercase. A trailing dot, as in example.com., denotes a fully qualified name in DNS configuration files; in browsers and most user interfaces it is omitted.
Registry-specific policies
Beyond the technical rules, each TLD registry sets policies: reserved or premium names, minimum lengths, eligibility requirements (for example, residency for some country-code TLDs) and accepted IDN scripts. Registrars apply these rules when you search, so a name that is technically valid may still be unavailable for policy reasons.
Validating names in software
- Split the name on dots and check each label's length (1–63) and the total length (up to 253 characters).
- Convert internationalized names to Punycode before checking lengths.
- Check that each label uses only allowed characters and does not start or end with a hyphen.
- Do not assume the TLD list is fixed; new TLDs are added over time.
Key takeaways
- Labels are 1–63 octets; the full name is at most 253 characters in text form.
- Registered host names use letters, digits and hyphens, with no leading or trailing hyphen.
- IDNs are encoded as
xn--labels, and limits apply to the encoded form. - Registries add their own rules on top of the technical standards.