Angular pipe for smart capitalization of person names. Handles compound surnames, particles (de, del, la, van, von...), hyphenated names, apostrophes, and Unicode characters.
Built on top of name-capitalize.
| ngx-name-capitalize | Angular | Node |
|---|---|---|
| 1.x | 12 – 13 | >= 16 |
| 2.x | 14 – 15 | >= 18 |
| 3.x | 16+ | >= 18 |
npm install ngx-name-capitalizeimport { NameCapitalizePipe } from 'ngx-name-capitalize';
@Component({
standalone: true,
imports: [NameCapitalizePipe],
template: `{{ name | namecase }}`
})
export class MyComponent { }import { NgxNameCapitalizeModule } from 'ngx-name-capitalize';
@NgModule({
imports: [NgxNameCapitalizeModule]
})
export class AppModule { }{{ 'JUAN DE LA MAZA' | namecase }}
<!-- Output: Juan de la Maza -->
{{ "bernardo o'higgins riquelme" | namecase }}
<!-- Output: Bernardo O'Higgins Riquelme -->
{{ 'jean-pierre dupont' | namecase }}
<!-- Output: Jean-Pierre Dupont -->import { NameCapitalizePipe } from 'ngx-name-capitalize';
@Component({
providers: [NameCapitalizePipe]
})
export class MyComponent {
constructor(private namecase: NameCapitalizePipe) {}
format(name: string): string {
return this.namecase.transform(name);
}
}| Input | Output |
|---|---|
JUAN DE LA MAZA |
Juan de la Maza |
ludwig van beethoven |
Ludwig van Beethoven |
BERNARDO O'HIGGINS |
Bernardo O'Higgins |
jean-pierre dupont |
Jean-Pierre Dupont |
gabriel garcía márquez |
Gabriel García Márquez |
MIGUEL DE CERVANTES Y SAAVEDRA |
Miguel de Cervantes y Saavedra |
van gogh |
Van Gogh |
MIT © Gabriel Galilea