Domains are registered for a fixed term, usually a year. Let it lapse and your website and email stop working. Wait past the grace period and someone else can register it.
RDAP
RDAP is the newer replacement for whois and returns JSON. Each TLD has its own RDAP server; IANA keeps the list at
https://data.iana.org/rdap/dns.json. For a .com:
curl -s https://rdap.verisign.com/com/v1/domain/example.com \
| jq -r '.events[] | select(.eventAction == "expiration") | .eventDate'
The domain expiry lookup does the same and finds the right server for you.
whois
whois example.com | grep -i -E 'expir|paid-till|renewal'
Every registry names the field differently, and some hide the date or rate-limit you.
Registries without RDAP dates
Most generic TLDs (.com, .net, .org, .dev, .io and the newer ones) publish the date over RDAP. Some country TLDs don't, .bg and .de among them. For those, look in your registrar's control panel.
Not losing it
- Turn on auto-renew, and update the card when it expires.
- Check where the registrar's reminder emails go. Often it's someone who left years ago.
- Keep an eye on the date yourself as well. Auto-renew doesn't help if the card on file is dead.