pluralize

Pluralize and singularize any English word based on a count, with customizable rules.

Library
npm
v8.0.0
2,212 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
44 /100 Fair
Development Activity 0
Maintenance 20
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 72
Code Quality 78
Innovation 60
Learning Curve 90

pluralize is a zero-dependency JavaScript library that converts words between singular and plural form using an ordered list of regex-based rules layered with explicit irregular-word and uncountable-word overrides (“person” → “people”, “sheep” stays “sheep”). A single pluralize(word, count, inclusive) call handles the common case of formatting a count alongside a word.

Because the rule set is exposed and mutable (addPluralRule, addSingularRule, addIrregularRule, addUncountableRule), consumers can extend or override the built-in English rules for domain-specific vocabulary without forking the library, which is why it’s a common dependency inside larger NLP, ORM, and code-generation tools.

What You Get

  • pluralize(word, count?, inclusive?) to pluralize or singularize based on a count, optionally prefixing the count itself
  • pluralize.plural(word) / pluralize.singular(word) for direct, count-independent conversion
  • pluralize.isPlural(word) / pluralize.isSingular(word) for detection without conversion
  • pluralize.addPluralRule(rule, replacement) / addSingularRule to register custom regex-based conversion rules
  • pluralize.addIrregularRule(single, plural) for exception pairs that don’t follow any regular pattern
  • pluralize.addUncountableRule(word) to mark a word as invariant between singular and plural

Common Use Cases

  • Generating human-readable counts in UI copy (e.g. “1 comment” vs “3 comments”) without hardcoding plural forms
  • Deriving table/model names from singular class names in ORMs and code generators
  • Normalizing user search terms to a canonical singular or plural form before matching
  • Building domain-specific vocabularies (medical, legal, gaming terms) by registering custom irregular/uncountable rules on top of the English defaults

Under The Hood

Architecture The entire library is a single UMD-wrapped file (pluralize.js, ~500 lines) exposing a function object. Internally it keeps four ordered collections — pluralRules, singularRules, uncountables, and irregularPlurals/irregularSingles — and a replaceWord/checkWord pair of higher-order functions that apply them in the correct precedence (irregular and uncountable lookups first, then the most-recently-added regex rule that matches). The bundled English rule set (addPluralRule/addSingularRule/addIrregularRule calls at the bottom of the file) is itself just data fed through the same public API consumers use to extend it, so there’s no special-cased internal path.

Tech Stack Zero runtime dependencies — the entire implementation is vanilla JavaScript wrapped in a UMD shim supporting CommonJS, AMD, and browser globals simultaneously. Tests use Mocha/Chai with Istanbul for coverage, and linting is done via semistandard. No build step is required since the published file is the source file.

Code Quality test.js runs a large table-driven suite of singular/plural word pairs alongside edge cases (case restoration, custom rule registration, uncountables), giving broad regression coverage for a rule-based system where a single regex change can silently break unrelated words. The rule precedence logic (restoreCase, sanitizeRule) is compact but has been stable since the last major version; the project has seen no commits in the last year, so any newly discovered English edge cases won’t be fixed upstream.

API Design The core function overloads pluralization and singularization based on the count argument’s relationship to 1, which keeps call sites terse (pluralize('item', n)) but means the same function name does two conceptually different things depending on the second argument — the explicit .plural()/.singular() methods exist specifically to avoid that ambiguity when the caller already knows the direction. The rule-registration functions accept both string and RegExp rules, letting simple cases stay declarative while power users get full regex control.

Used by 24 apps in this directory

TypeScript
99%
MIT

KeystoneJS

CMS · Developer Tools

9,980

The superpowered headless CMS for developers built with GraphQL and React

View details
92
Repo Health
81
Technical
64
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
98%
MPL 2.0

Logto

Authentication

14,769

Open-source auth infrastructure for SaaS and AI apps with OIDC, SAML, and RBAC

View details
92
Repo Health
83
Technical
63
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
87%
MIT

medusa

Ecommerce

36,897

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
94
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 87%
JavaScript 12%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago
Go
36%

OpenPanel

Devops · Hosting Control Panel

764

Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.

View details
87
Repo Health
75
Technical
63
Dependency
Built with
Go 36%
HTML 30%
TypeScript 24%
Updated 6 days ago
TypeScript
93%
Apache 2.0

Openship

Devops · Hosting Control Panel

14,912

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 93%
Updated 5 days ago
TypeScript
98%
Other

Outline

Collaboration · Knowledge Management

41,045

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 98%
Updated 5 days ago
JavaScript
98%
Apache 2.0

Parse Server

Databases · Developer Tools

21,401

Self-hosted Backend-as-a-Service for Node.js with REST, GraphQL, real-time Live Query, cloud code, and pluggable adapters for any infrastructure.

View details
98
Repo Health
81
Technical
70
Dependency
Built with
JavaScript 98%
Updated 6 days ago
TypeScript
96%
MIT

Payload CMS

Blogging · CMS · Developer Tools

45,458

The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.

View details
92
Repo Health
88
Technical
65
Dependency
Built with
TypeScript 96%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers