Free tool · no signup
DKIM record generator
Create a DKIM key pair in your browser and get the exact DNS record to publish, plus the private key for your mail server. The key never leaves your device.
By the Bug Circuit security team · Last updated
Your settings
The key is created in this browser with the Web Crypto API. Nothing is sent to us, stored, or logged.
Press the button to create a key pair. You will get the DNS record to publish at s2026._domainkey and the private key for your mail server.
How it works
How DKIM works
When your server sends a message, it adds a DKIM-Signature header: a signature over selected headers and the body, made with a private key. The header names a domain (d=) and a selector (s=). The receiving server looks up the public key in DNS at selector._domainkey.domain, verifies the signature and learns that the message really passed through a system that holds your key and was not changed on the way.
The selector lets you have several keys at once. Use a different selector for each service that signs mail for you, and a new one each time you rotate a key, so the old one can stay published until mail signed with it has been delivered.
When to use this tool, and when not to
Google Workspace, Microsoft 365, Mailchimp, SendGrid and most other email services create the key pair for you and show you the DNS record. Use theirs: their servers hold the private key, and a record from this tool would not match it. This generator is for a mail server you run, such as Postfix with OpenDKIM or a self-hosted mail suite, or a custom application that signs its own mail.
The private key is created with the Web Crypto API inside your browser tab. It is not sent to us, stored or logged. Copy it straight to your mail server, then close the page. Never publish it or commit it to a repository.
Key size and long records
Use 2048 bits. A 1024-bit key is considered weak, and receivers must accept keys up to 4096 bits (RFC 8301). A 2048-bit public key makes a TXT record of about 410 characters. DNS limits each string to 255 characters, so the record is published as two quoted strings that receivers join together. Most DNS dashboards do this for you when you paste the whole value, and the tool shows the split form for zone files.
DKIM is one of three checks. It proves the message was signed, SPF says which servers may send, and DMARC tells receivers what to do when they disagree. Set up all three, then test with the email spoofing checker.
Worked examples
The record to publish
Domain example.com, selector s2026, 2048 bits.
Name: s2026._domainkey.example.com Type: TXT Value: v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
The p= value is the whole public key on one line. The tool prints the real one for the key it just made.
The same record in a zone file
The value is longer than 255 characters, so it is split into two strings.
s2026._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkq...(first 255 characters)" "...(the rest)"
Receivers join the strings with nothing between them. Do not add a space or a line break inside the key.
Rotating a key
You used selector s2026 and want a new key in 2027.
Publish s2027._domainkey.example.com, switch the mail server to sign with s2027, then remove s2026._domainkey.example.com a few weeks later.
Rotating once a year is a reasonable habit. Keeping the old record for a while means mail that is still in transit keeps verifying.
Frequently asked questions
Is it safe to generate a DKIM key in a web page?
What selector should I use?
Do I still need SPF and DMARC?
My DNS host says the record is too long. What now?
How do I check that DKIM works?
Where does the private key go?
Should I use an Ed25519 key instead?
Keep reading
See what attackers see, for free
Run the free passive check on your website. No login, no impact on your site, results in seconds.
Ready for the full manual audit? See pricing