API
@agape/string

toSingular Function

Returns the singular form of a plural word.

API

function toSingular(  word: string): string

toSingular

string

Returns the singular form of a plural word.

@paramword:  string
Plural word to be converted to singular.
@returnsstring

Description

Returns the singular form of a plural word.

Handles common English pluralization patterns such as:

  • ies → y
  • es → base (for s, x, z, ch, sh endings)
  • s → base (general fallback)
  • known irregulars (e.g., children → child)

Preserves the casing of the original input, including acronyms or title case.

Usage

toSingular("cities"); // "city"
toSingular("boxes"); // "box"
toSingular("children"); // "child"
toSingular("teeth"); // "tooth"
toSingular("dogs"); // "dog"
toSingular("BUZZES"); // "BUZZ"
toSingular("IDs"); // "ID"