cd /news/developer-tools/a-tool-matcher-in-40-lines-of-vanill… · home › topics › developer-tools › article
[ARTICLE · art-182857] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

A tool matcher in ~40 lines of vanilla JavaScript

A developer built a roughly 40-line vanilla JavaScript tool matcher for a small AI tools directory, mapping user tasks to recommended tools via data attributes and a plain object lookup. The matcher uses native button elements for keyboard support, aria-pressed for selection state, and an aria-live region for results, with tool data kept in a single object so adding a tool requires only one line. The developer packaged it into a static site with search, guides, and 12 tools, offering a live demo and paid source.

key takeaway

A task-to-tool matcher can be built in about 40 lines of vanilla JavaScript by storing tools in a plain object keyed by task and using data-match buttons with aria-pressed and an aria-live result region.

by read1 min views1 publishedDec 6, 2026

When I built a small AI tools directory, the feature people actually used was not the tool list - it was one question: "what are you trying to do?"

Here is the whole matcher. No framework, no state library, ~40 lines.

const tools = {
  writing:  { name: "Claude",     why: "long-form drafting and editing" },
  design:   { name: "Canva",      why: "social graphics without a designer" },
  research: { name: "Perplexity", why: "answers with sources you can check" },
  admin:    { name: "Zapier",     why: "gluing apps together" },
};

const choices = document.querySelectorAll("[data-match]");
const result = document.querySelector("#match-result");

choices.forEach((button) => {
  button.addEventListener("click", () => {
    const task = button.dataset.match;
    const tool = tools[task];
    if (!tool) return;

    choices.forEach((b) => b.setAttribute("aria-pressed", String(b === button)));
    result.hidden = false;
    result.innerHTML =
      "<strong>" + tool.name + "</strong> - " + tool.why +
      ' <a href="https://example.com" rel="noopener">Visit site</a>';
  });
});

Three things that made it feel good to use:

<button type="button" data-match="writing"> gets keyboard support for free.aria-pressed for state.aria-live="polite" on the result. The data stays in a plain object, so adding a tool means adding one line. If you later want search, filter Object.entries(tools) - the matcher and the list can share the same source of truth.

I wrapped this into a complete static site (search, guides, 12 tools) - live demo: https://toolroom-ai-tools.netlify.app - and the source is available here: https://payhip.com/b/5j0hC if you want to skip the setup.

── more in #developer-tools 4 stories · sorted by recency
── more on @claude 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-tool-matcher-in-40…] indexed:0 read:1min 2026-12-06 · —