What is lowercase-keys?
The lowercase-keys npm package is designed to convert the keys of an object to lowercase. It is a simple utility that can be particularly useful when dealing with data that may have inconsistent capitalization in its keys and you need to ensure uniformity for processing or matching purposes.
What are lowercase-keys's main functionalities?
Lowercase Object Keys
This feature allows you to convert all keys in an object to lowercase. It's particularly useful for normalizing data received from different sources that may not adhere to a consistent capitalization scheme.
{"const lowercaseKeys = require('lowercase-keys');\nconst myObj = {'Name': 'John', 'AGE': 30, 'Country': 'USA'};\nconst lowercasedObj = lowercaseKeys(myObj);\nconsole.log(lowercasedObj); // Output: { name: 'John', age: 30, country: 'USA' }"}
Other packages similar to lowercase-keys
camelcase-keys
Similar to lowercase-keys, camelcase-keys converts the keys in an object to camelCase. It's useful for situations where camelCase is the desired or required key format, providing a different kind of normalization compared to lowercase-keys.
snakecase-keys
This package converts object keys to snake_case. It serves a similar purpose to lowercase-keys in terms of normalizing key names, but it targets a different naming convention, offering flexibility depending on the specific case format needs.
lowercase-keys
Lowercase the keys of an object
Check out map-obj
if you need support for deep iteration.
Install
npm install lowercase-keys
Usage
import lowercaseKeys from 'lowercase-keys';
lowercaseKeys({FOO: true, bAr: false});
API
lowercaseKeys(object)
Returns a new object with the keys lowercased.
lowercase-keys for enterprise
Available as part of the Tidelift Subscription.
The maintainers of lowercase-keys and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.