npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

name-to-gender

v1.0.1

Published

Guess gender from a first name using US Social Security data. Returns a probability and the raw birth counts. TypeScript, ESM + CJS, zero dependencies.

Readme

name-to-gender

Predict the gender of a first name from US Social Security birth data. A fast, accurate, zero-dependency library for Node.js and TypeScript that turns a name into a gender, a confidence probability, and the raw birth counts behind every guess.

npm version npm downloads bundle size license GitHub stars

name-to-gender is a gender detection and gender prediction library that infers gender from a person's first name. Give it a name like "Adam" or "Mary" and it returns "male", "female", or "unknown", along with a probability you can threshold on. It is data-driven rather than rule-based, ships its dataset offline with the package, and has zero runtime dependencies.

import { guessGender } from "name-to-gender";

guessGender("Adam");
// {
//   gender: "male",
//   probability: 0.996,
//   counts: { male: 523494, female: 2002 },
//   name: "adam"
// }

Features

  • Accurate. Backed by 91,000+ names and all-time US birth counts, so common names resolve correctly instead of being guessed from spelling.
  • Confidence scores. Every result carries a probability and the raw { male, female } counts, so you decide where to draw the line.
  • Unisex-aware. Threshold low-confidence names like Casey or Jordan down to "unknown" with a single option.
  • Forgiving input. Handles full names, casing, accents, and punctuation out of the box.
  • TypeScript-first. Full types, ESM and CommonJS builds, tree-shakeable, zero dependencies.
  • Offline. No API calls, no network, no rate limits. The data ships in the package.

Install

npm install name-to-gender
pnpm add name-to-gender
yarn add name-to-gender

Usage

guessGender(name, options?)

The main entry point. Pass a name, get back a gender, a probability, and the counts.

import { guessGender } from "name-to-gender";

guessGender("Mary");
// { gender: "female", probability: 0.995, counts: { male: 7732, female: 1467208 }, name: "mary" }

// Messy input is handled: full names, casing, accents, and punctuation.
guessGender("  José Martinez ").gender; // "male"  (uses the first token, folds accents)
guessGender("::Jenni♥fer::").name; // "jennifer"

// Names not in the dataset return "unknown" with a zero probability.
guessGender("Xyzzy");
// { gender: "unknown", probability: 0, counts: { male: 0, female: 0 }, name: "xyzzy" }

Thresholding unisex names

Some names are unisex. Pass minProbability to treat low-confidence guesses as "unknown" while still seeing the underlying numbers:

guessGender("Casey"); // gender: "male" (≈59% male)
guessGender("Casey", { minProbability: 0.9 }); // gender: "unknown", probability: 0.59, counts: {...}

isMale(name, options?) / isFemale(name, options?)

Convenience booleans. Both return false for unknown or below-threshold names.

import { isMale, isFemale } from "name-to-gender";

isMale("Ryan"); // true
isFemale("Ryan"); // false

Result shape

interface GenderGuess {
  gender: "male" | "female" | "unknown";
  probability: number; // P(gender), in [0.5, 1]; 0 when unknown
  counts: { male: number; female: number };
  name: string | null; // the normalized name that was looked up
}

How it works

name-to-gender is data-driven, not rule-based. It normalizes the input to a first-name token, looks it up in a table of all-time US births by name and sex, and reports the majority sex along with its share. There are no "ends in -a means female" heuristics, which is why it resolves names like Adam, Joshua, and Andrea correctly.

The dataset is built from the public-domain US Social Security Administration baby-names data, aggregated across every birth year from 1880 to the present into 91,000+ names. It works best for US and English-context names. See CONTRIBUTING.md for how to regenerate it from the latest SSA release.

Comparison with other packages

There are several similar packages on npm. Here is how they line up. name-to-gender aims to be the best, most current, and typed.

| Package | Data | Last updated | Confidence score | TypeScript types | | ---------------------------------------------------------------------------------------- | --------------------- | ------------ | ---------------- | ---------------- | | gender | US Census | 2013 | yes | no | | gender-guess | SSA 1930–2013 | 2014 | yes | no | | gender-detection | mixed | 2018 | no | no | | gender-detection-from-name | mixed | 2025 | no | no | | name-to-gender | US SSA, all years | current | yes | yes |

If you are migrating from one of the packages above, guessGender(name) is the closest drop-in. It returns a label like the others, plus the probability and counts they leave out.

FAQ

How do I get the gender of a name in JavaScript or TypeScript?

Install name-to-gender and call guessGender("Alex"). You get back { gender, probability, counts, name }. No API key and no network request are required.

How accurate is it?

Accuracy depends on the name. Strongly gendered names like Mary or John resolve at well over 99% confidence. Unisex names like Casey or Jordan land near 50%, and the returned probability tells you exactly how confident the guess is so you can threshold accordingly.

Does it work offline, without an API?

Yes. The full dataset is bundled in the package, so every lookup is local, synchronous, and free. There are no rate limits or external calls.

Can it handle full names, accents, and messy input?

Yes. It extracts the first-name token, folds accents (José to jose), lowercases, and strips punctuation before looking the name up.

What about unisex or non-binary names?

The library reports the statistical male/female split from US birth records. For unisex names the probability sits near 0.5. Use the minProbability option to fold low-confidence names into "unknown" rather than forcing a binary label.

What data is it based on?

Public-domain US Social Security Administration baby-names data, summed across all birth years from 1880 onward. It is tuned for US and English-context names.

Use cases

  • Personalizing greetings, salutations, and email copy
  • Enriching CRM, analytics, and demographic data
  • Pre-filling or validating form fields
  • Audience segmentation and reporting
  • Cleaning and labeling datasets for machine learning

License

MIT © Michael Cummings