Interactive Demo
Enter any name to see it classified (person, organization, family, compound) with confidence scores.
Try: Acme Corp, Inc. | Bob & Mary Smith | The Smith Family |
Smith, John, Jr.
Gender Probability Lookup
Look up gender probability based on US Social Security Administration data.
Try: Chris | Taylor | Jordan | Michael |
Jennifer
Pronoun Lookup
Get a complete pronoun set from a shorthand spec.
Try: he/him | she/her | ze/zir | xe/xem |
any
Pronouns for Entity
Uses entity classification + gender lookup to suggest appropriate pronouns.
Try: Mary Johnson | Acme Inc. | The Smith Family |
Alex (they/them)
Test Results - Live Parsing Validation
All test cases validated in real-time. Green = passing, Red = failing.
| Original String | Prefix | First | Nickname | Middle | Last | Suffix |
|---|
Installation
pnpm add name-tools
Quick Start
import { parseName, formatName } from 'name-tools';
// Parse and classify a name - returns a typed entity
const person = parseName("Dr. John Franklin Jr.");
console.log(person.kind); // 'person'
console.log(person.given); // 'John'
console.log(person.family); // 'Franklin'
// Detect organizations automatically
const org = parseName("Acme Corporation, Inc.");
console.log(org.kind); // 'organization'
// Detect compound names (couples)
const couple = parseName("Bob & Mary Smith");
console.log(couple.kind); // 'compound'
// Format names with presets
console.log(formatName("Dr. John Franklin Jr."));
// "John Franklin, Jr."
Features
- Entity Classification: Automatically detect person, organization, family, or compound names
- Parse Names: Extract components (prefix, first, middle, last, suffix, nickname)
- Format Names: Multiple formatting presets (display, formal, alphabetical, initialed)
- Reversed Names: Support for "Smith, John, Jr." format
- Recipient Lists: Parse email To/CC lines with parseNameList()
- TypeScript Support: Full type definitions with discriminated unions
- Zero Dependencies: Lightweight and fast
API Reference
Classification & Parsing
parseName(input, options?)- Classify and parse into entity type (person, org, family, compound)parseNameList(input)- Parse email recipient lists (To/CC lines)getFirstName(fullName)- Extract first namegetLastName(fullName)- Extract last name
Type Guards
isPerson(entity)- Check if entity is a personisOrganization(entity)- Check if entity is an organizationisFamily(entity)- Check if entity is a family/householdisCompound(entity)- Check if entity is a compound name
Formatting Functions
formatName(input, options?)- Single rendering entry point (presets + options)
Data & Utilities
PARTICLES- Array of surname particles (van, von, de, etc.)COMMON_SURNAMES,COMMON_FIRST_NAMES- Name datasetsisParticle(),isCommonSurname(),isCommonFirstName()
Pronouns
getPronounSet(spec)- Get complete pronoun set from "he/him", "she/her", etc.getPronouns(entity, options?)- Get pronouns for any entity with optional gender lookupformatPronoun(set, role, options?)- Format a single pronoun with capitalizationfillPronounTemplate(template, set)- Fill {{subject}}, {{object}}, etc. placeholdersextractPronouns(name)- Extract pronouns from "Alex (they/them)" formatBUILT_IN_PRONOUNS- Map of built-in pronoun sets (he, she, they, ze-hir, etc.)