Uppercase object keys

JavaScript, Object · Feb 11, 2023

Converts all the keys of an object to upper case.

const upperize = obj =>
  Object.keys(obj).reduce((acc, k) => {
    acc[k.toUpperCase()] = obj[k];
    return acc;
  }, {});
upperize({ Name: 'John', Age: 22 }); // { NAME: 'John', AGE: 22 }

Written by Angelos Chalaris

I'm Angelos Chalaris, a JavaScript software engineer, based in Athens, Greece. The best snippets from my coding adventures are published here to help others learn to code.

If you want to keep in touch, follow me on GitHub or Twitter.

More like this

  • Lowercase object keys

    Converts all the keys of an object to lower case.

    JavaScript, Object · Feb 12, 2023

  • Symbolize object keys

    Creates a new object, converting each key to a Symbol.

    JavaScript, Object · Aug 1, 2021

  • Rename object keys

    Replaces the names of multiple object keys with the values provided.

    JavaScript, Object · Oct 22, 2020