Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

camelcase-to-snakecase

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camelcase-to-snakecase

Converts camelcase to snakecase

  • 1.1.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

CamelCase to snake_case Javascript

Convert all your objects with camelCase properties to snake_case 👀🎉

Install

npm install camelcase-to-snakecase

# Or
yarn add camelcase-to-snakecase

# CDN
unpkg
https://unpkg.com/camelcase-to-snakecase@latest/src/index.js

jsdelivr
https://cdn.jsdelivr.net/npm/camelcase-to-snakecase@latest/src/index.min.js

Import

const { camelCaseToSnakeCase, replaceCamelCaseObj } = require('camelcase-to-snakecase');

Usage

// Converting a camelCase object to snake_case
const objInCamelCase = {
  userName: 'josue_ayala',
  favoriteColors: ['red', 'green', 'blue'],
  other: { firstName: 'Josue', lastName: 'Ayala' }
};

console.log(replaceCamelCaseObj(objInCamelCase));

/* returns
{
  user_name: 'josue_ayala',
  favorite_colors: [ 'red', 'green', 'blue' ],      
  other: { first_name: 'Josue', last_name: 'Ayala' }
}  
*/

// Converting a string camelCase to snake_case
const camelCase = 'thisIsMyCamelCaseConst';

console.log(camelCaseToSnakeCase(camelCase));

/* returns
this_is_my_camel_case_const 
*/

License

MIT

Keywords

FAQs

Package last updated on 03 Aug 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc