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

universal-name-formatter

v1.0.2

Published

Universal name formatter with locale-specific support for proper name capitalization across languages

Readme

Universal Name Formatter

npm version License: MIT

A locale-aware name formatting utility that handles international names with proper linguistic rules. Supports 17+ languages including Spanish, French, Italian, German, Dutch, Irish, and Scottish names.

Features

  • Universal Linguistic Rules - Handles complex name patterns across languages
  • Locale-Specific Formatting - French articles vs Italian surnames (d'Aubigny vs D'Amico)
  • Zero Dependencies - Lightweight (11.5 kB compressed)
  • TypeScript Support - Full type safety
  • Legacy Compatible - CommonJS + ESM support

Installation

npm install universal-name-formatter

Quick Start

import { formatName } from 'universal-name-formatter';

// Universal formatting
formatName('josé maría de la cruz');         // "José María de la Cruz"
formatName('jean-claude van damme');         // "Jean-Claude van Damme"
formatName('leonardo da vinci');             // "Leonardo da Vinci"

// Locale-specific precision
formatName('marie d\'aubigny', { locale: 'fr' });  // "Marie d'Aubigny"
formatName('giovanni d\'amico', { locale: 'it' }); // "Giovanni D'Amico"

Supported Languages

| Language | Example | Output | |----------|---------|--------| | Spanish | josé maría de la cruz | José María de la Cruz | | French | jean-claude de la fontaine | Jean-Claude de la Fontaine | | German | hans von neumann | Hans von Neumann | | Dutch | jan van der waals | Jan van der Waals | | Italian | leonardo da vinci | Leonardo da Vinci | | Irish | patrick o'malley | Patrick O'Malley | | Scottish | donald mcdonald | Donald McDonald |

Plus: Catalan, Swedish, Norwegian, Danish, Welsh, Galician, Polish, Czech, Romanian

API

formatName(name, options?)

Parameters:

  • name (string): The name to format
  • options (object, optional):
    • locale (string): Language code (e.g., 'fr', 'it', 'es')
    • trim (boolean): Trim whitespace (default: true)
    • normalizeSpaces (boolean): Normalize spaces (default: true)

Returns: Formatted name string

Locale Examples

// French - keeps articles lowercase
formatName("marie d'aubigny", { locale: "fr" });     // "Marie d'Aubigny"

// Italian - capitalizes surnames  
formatName("giovanni d'amico", { locale: "it" });    // "Giovanni D'Amico"

// Spanish - handles prepositions
formatName("maría de la cruz", { locale: "es" });    // "María de la Cruz"

// German - von/zu prefixes
formatName("ludwig van beethoven", { locale: "de" }); // "Ludwig van Beethoven"

Advanced Usage

// Handle mixed origins
formatName('maría von habsburg');        // "María von Habsburg"
formatName('jean-claude mcdonald');      // "Jean-Claude McDonald"

// Custom options
formatName('  marie d\'aubigny  ', {
  locale: 'fr',
  trim: true,
  normalizeSpaces: true
});

TypeScript

import { formatName, type NameFormatterOptions } from 'universal-name-formatter';

const options: NameFormatterOptions = {
  locale: 'fr',
  trim: true
};

const formatted: string = formatName('marie d\'aubigny', options);

License

MIT - see LICENSE file for details.