decamelize (5.0.1)

Published 2026-02-24 13:55:12 +00:00 by atheaadmin

Installation

registry=
npm install decamelize@5.0.1
"decamelize": "5.0.1"

About this package

decamelize

Convert a camelized string into a lowercased one with a custom separator
Example: unicornRainbowunicorn_rainbow

If you use this on untrusted user input, don't forget to limit the length to something reasonable.

Install

$ npm install decamelize

Usage

const decamelize = require('decamelize');

decamelize('unicornRainbow');
//=> 'unicorn_rainbow'

decamelize('unicornRainbow', {separator: '-'});
//=> 'unicorn-rainbow'

decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
//=> 'test_GUI_label'

decamelize('testGUILabel', {preserveConsecutiveUppercase: false});
//=> 'test_gui_label'

API

decamelize(input, options?)

input

Type: string

options

Type: object

separator

Type: string
Default: '_'

Character or string inserted to separate words in string.

cosnt decamelize = require('decamelize');

decamelize('unicornRainbow');
//=> 'unicorn_rainbow'

decamelize('unicornRainbow', {separator: '-'});
//=> 'unicorn-rainbow'
preserveConsecutiveUppercase

Type: boolean
Default: false

Preserve sequences of uppercase characters.

const decamelize = require('decamelize');

decamelize('testGUILabel');
//=> 'test_gui_label'

decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
//=> 'test_GUI_label'

See camelcase for the inverse.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Dependencies

Development Dependencies

ID Version
ava ^2.4.0
tsd ^0.11.0
xo ^0.24.0

Keywords

decamelize decamelcase camelcase lowercase case dash hyphen string text convert
Details
npm
2026-02-24 13:55:12 +00:00
0
Sindre Sorhus
MIT
latest
2.7 KiB
Assets (1)
Versions (3) View all
4.0.0 2026-02-24
5.0.1 2026-02-24
1.2.0 2026-02-24