Overview
Introduction
Every domain name inside a DNS message is encoded as a sequence of length-prefixed labels, but when the same name (or a suffix of it) shows up more than once, the protocol compresses it into a 2-byte back-pointer instead of repeating it.
This tool encodes a list of names in the order they'd appear in a message and shows exactly which ones got compressed, and how many bytes that saved.
What Is DNS Name Compression Tool?
An educational encoder that turns domain names into DNS wire-format bytes, applying RFC 1035's name compression algorithm exactly as a real DNS server or resolver would.
It's part of this site's DNS & Domain Tools collection and runs entirely offline; it's a protocol visualizer, not a live lookup.
How DNS Name Compression Tool Works
Each name is checked against every suffix of every name already encoded earlier in the sequence; the longest matching suffix becomes a pointer instead of being spelled out.
Labels that aren't compressed are written as a length byte followed by their ASCII bytes, terminated by a zero byte for the root; a pointer instead uses two bytes with the top two bits set (0xC0) followed by the target offset.
When To Use DNS Name Compression Tool
Use it to see concretely how much DNS message compression actually saves for a realistic set of names, like a domain's several subdomains appearing together in a response.
It's also useful as a learning aid when implementing or debugging low-level DNS parsing code that needs to follow compression pointers correctly.
Often used alongside MX Record Lookup and DNS Propagation Checker.
Features
Advantages
- Shows the exact byte sequence and offsets involved, not just an abstract description of the algorithm.
- Computes real savings numbers by comparing against what the same names would cost fully uncompressed.
Limitations
- This is a standalone visualizer, not a full DNS message: it doesn't build a real header, question, or resource record sections around the encoded names.
- Capped at 12 names per run to keep the byte table readable.
Examples
Best Practices & Notes
Best Practices
- Order names the way they'd actually appear in a real message (question first, then answers) to get a realistic compression picture.
- Try a batch of unrelated domains alongside related subdomains to see how little compression helps when there's no shared suffix to point to.
Developer Notes
Offsets start at 12 to model where the question section begins in a real DNS message after its fixed header, and the dictionary only ever stores offsets for label sequences actually written to the simulated message, matching how RFC 1035 restricts valid pointer targets to positions that hold a real (non-pointer) label sequence.
DNS Name Compression Tool Use Cases
- Teaching or learning exactly how DNS message compression works at the byte level
- Estimating how much a specific batch of names would benefit from compression before optimizing a DNS server implementation
- Debugging a hand-rolled DNS parser that isn't following compression pointers correctly
Common Mistakes
- Assuming every repeated substring compresses; only suffixes that align exactly with a previously written label sequence qualify, not arbitrary repeated text.
- Forgetting that a pointer's target offset is measured from the very start of the DNS message, not from the start of the name section.
Tips
- Enter completely unrelated domains to see the case where no compression is possible; every name should show its full uncompressed size.