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

normalize-human-name

v1.0.9

Published

🎓 Normalize real human names the way they’re actually written — fixes casing, particles, honorifics, suffixes, hyphenation, Mc/Mac and O’ prefixes into clean, properly formatted names.

Readme

normalize-human-name

  • 🎓 Normalize real human names the way they’re actually written — fixes casing, particles, honorifics, suffixes, hyphenation, Mc/Mac and O’ prefixes into clean, properly formatted names.
  • ♻️ Works seamlessly with CommonJS, ESM and TypeScript
  • 0 Dependencies

🤔 Why this module is Versatile

  • Most name normalization functions simply capitalize the first letter of every word. normalizeHumanName is built to handle the "messy" reality of human nomenclature by implementing rules for honorifics, genealogical suffixes, and complex prefixes.

Key Capabilities:

  • 🛡️ Context-Aware Particles: Automatically keeps Dutch and Romance language particles (like van, von, di) lowercase, but only when they appear in the middle of a name.
  • 🏴󠁧󠁢󠁳󠁣󠁴󠁿 Gaelic Prefix Logic: Intelligent handling of Mc and Mac prefixes while excluding common false positives like "Macy" or "Mack".
  • 🔗 Smart Delimiter Handling: Splits and capitalizes correctly across both hyphens and apostrophes (e.g., O'Brian-Smith).
  • 🌐 Unicode Safety: Uses NFC normalization to ensure that accented characters (like é) are treated as single units, preventing "double-casing" bugs.
  • 🎓 Academic & Professional Sets: Detects specific suffixes like PhD, MD, or JR and ensures they maintain standard uppercase formatting.

Edge Case Handling

| Input Category | Example Input | Normalized Output | Why it’s handled this way | | :--- | :--- | :--- | :--- | | Honorifics | dr stephen strange | Dr. Stephen Strange | Detects titles and ensures a standardized trailing period. | | Suffixes | robert downey jr | Robert Downey JR | Identifies genealogical and professional suffixes to force uppercase. | | Middle Particles | vincent van gogh | Vincent van Gogh | Particles stay lowercase between names but capitalize at boundaries. | | Hyphenated Gaelic | o'brian-mcdonald | O’Brian-McDonald | Recursively handles multiple delimiters and converts to smart apostrophes. | | Exclusion Logic | macy gray | Macy Gray | Prevents "Mac" logic from triggering on names that aren't actually prefixes. | | Unicode Normalization | REN\u0065\u0301 | René | Collapses decomposed accents into single characters before processing. | | Sanitization | JOHN DOE | John Doe | Collapses internal whitespace and trims the string. | | Arabic Script | نجيب محفوظ | نجيب محفوظ | Detects Arabic Unicode script and returns as-is (Arabic has no concept of casing). | | CJK Script | 佐藤 健 | 佐藤健 | Detects Han/Hiragana/Katakana/Hangul and removes internal whitespace. | | Expanded Honorifics| rev brown | Rev. Brown | Now supports religious (Rev, Sister, Rabbi) and formal (Don, Herr) titles. | | Professional Suffixes| jane doe cpa | Jane Doe CPA | Forces uppercase for business and medical credentials (CPA, MBA, JD, DDS). | | International Particles| luca della robbia | Luca della Robbia | Handles extended Romance (della, dos) and Germanic (vander, zu) connectors. | | Roman Numerals | king henry viii | King Henry VIII | Uses strict regex to distinguish valid Roman numerals from regular words. |


📦 Install via NPM

$ npm i normalize-human-name

💻 Usage

  • See examples below

CommonJS

const normalizeHumanName = require('normalize-human-name');

// --| 1. The "Professional" (Honorifics & Suffixes)
// --| Handles title dots and uppercase credentials automatically
const academic = () => {
    const raw = "dr jane doe phd";
    console.log(normalizeHumanName(raw));
    // --| Result: "Dr. Jane Doe PHD"
};

// --| 2. The "European" (Middle Particles)
// --| Keeps connectors lowercase only when they are not at the start/end
const european = () => {
    const raw = "LEONARDO DI CAPRIO";
    console.log(normalizeHumanName(raw));
    // --| Result: "Leonardo di Caprio"
};

// --| 3. The "Highlander" (Gaelic Prefixes)
// --| Handles internal capitalization for Mc/Mac
const gaelic = () => {
    const raw = "mcdonald macdougal";
    console.log(normalizeHumanName(raw));
    // --| Result: "McDonald MacDougal"
};

// --| 4. The "Double-Barrel" (Hyphens & Apostrophes)
// --| Correctly cases across delimiters and converts to smart apostrophes
const hyphenated = () => {
    const raw = "anne-marie o'malley";
    console.log(normalizeHumanName(raw));
    // --| Result: "Anne-Marie O’Malley"
};

// --| 5. The "False Positive" (Exclusion Logic)
// --| Ensures common names starting with "Mac" aren't broken
const exclusion = () => {
    const raw = "macy gray";
    console.log(normalizeHumanName(raw));
    // --| Result: "Macy Gray" (Not "MacY")
};

// --| 6. The "International" (Unicode NFC)
// --| Prevents double-casing by collapsing decomposed characters
const international = () => {
    const raw = "REN\u0065\u0301";
    console.log(normalizeHumanName(raw));
    // --| Result: "René"
};

// --| 7. The "Messy Data" (Sanitization)
// --| Cleans up erratic spacing and mixed casing
const cleanup = () => {
    const raw = "  jOHN    smith   ";
    console.log(normalizeHumanName(raw));
    // --| Result: "John Smith"
};

// --| Execute all
[academic, european, gaelic, hyphenated, exclusion, international, cleanup].forEach(fn => fn());

ESM

import normalizeHumanName from 'normalize-human-name';

// --| 1. The "Professional" (Honorifics & Suffixes)
// --| Handles title dots and uppercase credentials automatically
const academic = () => {
    const raw = "dr jane doe phd";
    console.log(normalizeHumanName(raw));
    // --| Result: "Dr. Jane Doe PHD"
};

// --| 2. The "European" (Middle Particles)
// --| Keeps connectors lowercase only when they are not at the start/end
const european = () => {
    const raw = "LEONARDO DI CAPRIO";
    console.log(normalizeHumanName(raw));
    // --| Result: "Leonardo di Caprio"
};

// --| 3. The "Highlander" (Gaelic Prefixes)
// --| Handles internal capitalization for Mc/Mac
const gaelic = () => {
    const raw = "mcdonald macdougal";
    console.log(normalizeHumanName(raw));
    // --| Result: "McDonald MacDougal"
};

// --| 4. The "Double-Barrel" (Hyphens & Apostrophes)
// --| Correctly cases across delimiters and converts to smart apostrophes
const hyphenated = () => {
    const raw = "anne-marie o'malley";
    console.log(normalizeHumanName(raw));
    // --| Result: "Anne-Marie O’Malley"
};

// --| 5. The "False Positive" (Exclusion Logic)
// --| Ensures common names starting with "Mac" aren't broken
const exclusion = () => {
    const raw = "macy gray";
    console.log(normalizeHumanName(raw));
    // --| Result: "Macy Gray" (Not "MacY")
};

// --| 6. The "International" (Unicode NFC)
// --| Prevents double-casing by collapsing decomposed characters
const international = () => {
    const raw = "REN\u0065\u0301";
    console.log(normalizeHumanName(raw));
    // --| Result: "René"
};

// --| 7. The "Messy Data" (Sanitization)
// --| Cleans up erratic spacing and mixed casing
const cleanup = () => {
    const raw = "  jOHN    smith   ";
    console.log(normalizeHumanName(raw));
    // --| Result: "John Smith"
};

// --| Execute all
[academic, european, gaelic, hyphenated, exclusion, international, cleanup].forEach(fn => fn());

TypeScript

import normalizeHumanName from 'normalize-human-name';

// --| 1. The "Professional" (Honorifics & Suffixes)
// --| Handles title dots and uppercase credentials automatically
const academic = (): void => {
    const raw: string = "dr jane doe phd";
    console.log(normalizeHumanName(raw));
    // --| Result: "Dr. Jane Doe PHD"
};

// --| 2. The "European" (Middle Particles)
// --| Keeps connectors lowercase only when they are not at the start/end
const european = (): void => {
    const raw: string = "LEONARDO DI CAPRIO";
    console.log(normalizeHumanName(raw));
    // --| Result: "Leonardo di Caprio"
};

// --| 3. The "Highlander" (Gaelic Prefixes)
// --| Handles internal capitalization for Mc/Mac
const gaelic = (): void => {
    const raw: string = "mcdonald macdougal";
    console.log(normalizeHumanName(raw));
    // --| Result: "McDonald MacDougal"
};

// --| 4. The "Double-Barrel" (Hyphens & Apostrophes)
// --| Correctly cases across delimiters and converts to smart apostrophes
const hyphenated = (): void => {
    const raw: string = "anne-marie o'malley";
    console.log(normalizeHumanName(raw));
    // --| Result: "Anne-Marie O’Malley"
};

// --| 5. The "False Positive" (Exclusion Logic)
// --| Ensures common names starting with "Mac" aren't broken
const exclusion = (): void => {
    const raw: string = "macy gray";
    console.log(normalizeHumanName(raw));
    // --| Result: "Macy Gray" (Not "MacY")
};

// --| 6. The "International" (Unicode NFC)
// --| Prevents double-casing by collapsing decomposed characters
const international = (): void => {
    // --| \u0065\u0301 is a decomposed 'é'
    const raw: string = "REN\u0065\u0301";
    console.log(normalizeHumanName(raw));
    // --| Result: "René"
};

// --| 7. The "Messy Data" (Sanitization)
// --| Cleans up erratic spacing and mixed casing
const cleanup = (): void => {
    const raw: string = "  jOHN    smith   ";
    console.log(normalizeHumanName(raw));
    // --| Result: "John Smith"
};

// --| Execute all
const scenarios: Array<() => void> = [
    academic,
    european,
    gaelic,
    hyphenated,
    exclusion,
    international,
    cleanup
];

scenarios.forEach(fn => fn());