DEV Community

Rock
Rock

Posted on

How to Check Domain Availability Programmatically with Node.js

Ever had that moment where you finally land on the perfect name for your side project, only to find the .com is taken by a parked page from 2005? I've been there more times than I care to admit. It's a soul-crushing part of every developer's workflow.

The manual approach usually goes like this: type the name into a registrar, get disappointed, try adding "app" or "io" at the end, check again, repeat. It's tedious and kills momentum. What we really need is a programmatic way to batch-check ideas against domain availability.

Here's a simple approach using Node.js and the whois module to check multiple domain suggestions at once:

const whois = require('whois');

const domains = ['mycoolproject.com', 'mycoolproject.io', 'mycoolproject.dev', 'getcoolproject.com'];

async function checkDomain(domain) {
  return new Promise((resolve, reject) => {
    whois.lookup(domain, (err, data) => {
      if (err) {
        resolve({ domain, available: false, error: err });
        return;
      }
      // Simple heuristic: if whois data is minimal or contains "No match", it's likely available
      const available = !data || data.includes('No match') || data.includes('NOT FOUND');
      resolve({ domain, available });
    });
  });
}

async function checkAll() {
  const results = await Promise.all(domains.map(checkDomain));
  results.forEach(r => {
    console.log(`${r.domain}: ${r.available ? '✨ Available' : '❌ Taken'}`);
  });
}

checkAll();
Enter fullscreen mode Exit fullscreen mode

This script is great for a quick check, but you'll notice two problems: rate limiting and inconsistent whois responses. Different TLDs return different formats, and some registrars will throttle you after a few requests.

That's where a dedicated tool becomes useful. I recently used the SERPSpur Domain Suggestion Checker (https://serpspur.com/tool/domain-sugesstion-checker/) for a client project, and it handles the heavy lifting of parsing whois data across multiple TLDs simultaneously. It also suggests alternatives when your first choice is taken, which saves the "what about .co or .xyz?" mental loop.

The key takeaway here: don't let domain hunting become a blocker. Whether you build your own checker or use an existing one, the goal is to iterate fast. Your code is ready to ship, and the perfect domain is out there waiting.

Top comments (0)