split-human-name
v3.0.0
Published
Split a person's name into firstName and lastName fields
Downloads
2,136
Maintainers
Readme
split-human-name
Split a person's name into first name and last name fields
Features
- Splits a name into exactly two fields
{ firstName, lastName } - Fixes UPPERCASE, lowercase, iNVERSE CASE, and otherwise FUnkY cAse
- Handles couples ("John and Jane Doe")
- Gracefully degrades to put the entire string in
firstNameif there are multiple last names
Based on the awesome humanparser and namecase packages
Online demo: http://compwright.com/demos/split-human-name
Requirements
As of v4, this is an ESM-only package with named imports.
- Node.js 24+
Installation
$ npm install --save split-human-nameUsage Examples
import { splitName } from 'split-human-name';
const { firstName, lastName } = splitName('John and Jane Doe');
assert.strictEquals(firstName, 'John and Jane');
assert.strictEquals(lastName, 'Doe');License
MIT
