🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more
Socket
Book a DemoInstallSign in
Socket

decamelize

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decamelize

Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow

latest
Source
npmnpm
Version
6.0.1
Version published
Weekly downloads
41M
-1.34%
Maintainers
1
Weekly downloads
 
Created
Source

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

If you need Safari support, stay on version 3 until they implement regex lookbehinds.

Usage

import decamelize from '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: '_'

The character or string used to separate words.

import decamelize from 'decamelize';

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

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

Type: boolean
Default: false

Preserve sequences of uppercase characters.

import decamelize from 'decamelize';

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

decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
//=> 'test_GUI_label'
  • camelcase - The inverse of this package
  • decamelize-keys - Convert object keys from camel case

Keywords

decamelize

FAQs

Package last updated on 19 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts