sindresorhus/humanize-string

Convert a camelized/dasherized/underscored string into a humanized one: fooBar-Baz_Faz → Foo bar baz faz

112

stars

22

commits

JavaScript

primary language

Sep 12, 2025

updated

README

humanize-string

Convert a camelized/dasherized/underscored string into a humanized one Example: fooBar-Baz_FazFoo bar baz faz

Install

npm install humanize-string

Usage

import humanizeString from 'humanize-string';

humanizeString('fooBar');
//=> 'Foo bar'

humanizeString('foo-bar');
//=> 'Foo bar'

humanizeString('foo_bar');
//=> 'Foo bar'

API

humanizeString(input, options?)

input

Type: string

The string to humanize.

options

Type: object

preserveCase

Type: boolean
Default: false

Preserve the original case instead of lowercasing.

import humanizeString from 'humanize-string';

humanizeString('The-NetApp-Guide-to-Kubernetes');
//=> 'The net app guide to kubernetes'

humanizeString('The-NetApp-Guide-to-Kubernetes', {preserveCase: true});
//=> 'The NetApp Guide to Kubernetes'
  • camelcase - Convert a dash/dot/underscore/space separated string to camelcase

Contributors

sindresorhus

18 commits

BendingBender

2 commits

Richienb

1 commits

stoeffel

1 commits

sindresorhus/humanize-string

Convert a camelized/dasherized/underscored string into a humanized one: fooBar-Baz_Faz → Foo bar baz faz

112

stars

22

commits

JavaScript

primary language

Sep 12, 2025

updated

README

humanize-string

Convert a camelized/dasherized/underscored string into a humanized one Example: fooBar-Baz_FazFoo bar baz faz

Install

npm install humanize-string

Usage

import humanizeString from 'humanize-string';

humanizeString('fooBar');
//=> 'Foo bar'

humanizeString('foo-bar');
//=> 'Foo bar'

humanizeString('foo_bar');
//=> 'Foo bar'

API

humanizeString(input, options?)

input

Type: string

The string to humanize.

options

Type: object

preserveCase

Type: boolean
Default: false

Preserve the original case instead of lowercasing.

import humanizeString from 'humanize-string';

humanizeString('The-NetApp-Guide-to-Kubernetes');
//=> 'The net app guide to kubernetes'

humanizeString('The-NetApp-Guide-to-Kubernetes', {preserveCase: true});
//=> 'The NetApp Guide to Kubernetes'
  • camelcase - Convert a dash/dot/underscore/space separated string to camelcase

Contributors

sindresorhus

18 commits

BendingBender

2 commits

Richienb

1 commits

stoeffel

1 commits

Languages

JavaScript

89.3%

TypeScript

10.7%