JSON Convert all keys to lowercase

You are Here:

JSON Convert all keys to lowercase

There is no inbuilt method in javascript to convert all keys to lowercase. In this case, you have to use some logic to convert all keys to lowercase.

The following example will demonstrate how to convert all keys to lowercase.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>JSON Convert all keys to lowercase</h1> <button onclick="myFunction()">Click Me</button> <script> var data = [ { "name": "Mike", "age": 36 }, { "NAME": "Jade", "AGE": 24 } ]; function myFunction(){ for(var i = 0; i < data.length; i++){ for (var key in data[i]) { if(key.toLowerCase() !== key){ data[i][key.toLowerCase()] = data[i][key]; delete data[i][key]; } } } console.log(data); } </script> </body> </html>

Reminder

Hi Developers, we almost covered 100% of JSON Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JSON.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author