How to create a new object from the specified object, where all the keys are in lowercase in JavaScript? Last Updated : 17 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will learn how to make a new object from the specified object where all the keys are in lowercase using JavaScript. Example: Here, we have converted the upper case to lower case key values. Input: {RollNo : 1, Mark : 78} Output: {rollno : 1, mark : 78} Approach 1: A simple approach is to Extract keys from Object and LowerCase to all keys and make Object with them. For this purpose we use Object.keys( ) to extract keys from the object. And use String.toLowerCase() method to lower case keys and Array.reduce() method to make an object with lower-case strings. Example: This example shows the above-explained approach. JavaScript // Test Object const Student = { RollNo : 1, Mark: 78 }; // Function to lowercase keys function Conv( obj , key ) { obj[key.toLowerCase()] = Student[key]; return Student; } // Function to create object from lowercase keys function ObjKeys( obj) { let arr1 = Object.keys(obj); let ans = {}; for(let i of arr1) { Conv(ans,i); } return ans; } a = ObjKeys(Student); console.log(a); Output: { rollno : 1, mark : 78} Approach 2: The simplest approach is to convert the Object to an array and make keys lowercase and make objects from a new array. For this purpose, we use Object.entries() to make an array from Object. And we use Array.map() to apply String.toLowerCase() method to all keys. To convert a new array to an Object we use Object.fromEntries(). Example: This example shows the above-explained approach. JavaScript // Test Object const employ = { EmpId: 101, Batch: 56 }; // Converting Object to array let k = Object.entries(employ); // Apply toLowerCase function to all keys let l = k.map(function(t){ t[0] = t[0].toLowerCase() return t; } ); // Converting back array to Object const a = Object.fromEntries(l) console.log(a) Output: { empid : 101, batch : 56 } Comment More infoAdvertise with us Next Article How to Get all Property Values of a JavaScript Object without knowing the Keys? S satyam00so Follow Improve Article Tags : JavaScript Web Technologies javascript-functions JavaScript-Questions Similar Reads How to Create Array of Objects From Keys & Values of Another Object in JavaScript ? Creating an array of objects from the keys and values of another object involves transforming the key-value pairs of the original object into individual objects within an array. Each object in the array represents a key-value pair from the source object. Below approaches can be used to accomplish th 3 min read How to Get all Property Values of a JavaScript Object without knowing the Keys? To get all property values from a JavaScript object without knowing the keys involves accessing the object's properties and extracting their values.Below are the approaches to get all property values of a JavaScript Object:Table of ContentUsing Object.values() MethodUsing Object.keys() methodApproac 2 min read How to Create an Array of Object Literals in a Loop using JavaScript? Creating arrays of object literals is a very frequent activity in JavaScript, as often when working with data structures, several objects are needed. This article will allow your hand through different ways of coming up with an array of object literals in a loop in JavaScript. Here are different app 5 min read How to Append an Object as a Key Value in an Existing Object in JavaScript ? In JavaScript, An object is a key-value pair structure. The key represents the property of the object and the value represents the associated value of the property. In JavaScript objects, we can also append a new object as a Key-value pair in an existing object in various ways which are as follows. 3 min read How to Add Duplicate Object Key with Different Value to Another Object in an Array in JavaScript ? Adding duplicate object keys with different values to another object in an array in JavaScript refers to aggregating values under the same key from multiple objects in an array, creating a new object where each key corresponds to an array of associated values. Table of Content Using for...of LoopUsi 4 min read How to Create a Typed Array from an Object with Keys in TypeScript? Creating a typed array from the keys of an object in TypeScript ensures that your application maintains type safety, particularly when interacting with object properties. Here we'll explore different approaches to achieve this using TypeScript's built-in Object methods.Below are the approaches used 3 min read Like