interface stsInterface { [index: string]: string } const sts: stsInterface = { UserId: "AAAAAanbc:botocore-session", Account: "123456789012", Arn: "arn:aws:sts::123456789012:assumed-role/abc", Account1: "123456789012", Account2: "123456789012", Account3: "123456789012", } // find the key when value equal '123456789012'; // filter() will return Array back. // => not give "{}" will return value. const accountId2 = Object.keys(sts).filter( array => sts[array] === '123456789012'); // find the key when value equal '123456789012'; let accountId: string[] = []; Object.entries(sts).forEach( array => array[1] == '123456789012' ? accountId.push(array[0]) : false); console.log(accountId2); console.log('*'.repeat(50)); console.log(accountId); //[ 'Account', 'Account1', 'Account2', 'Account3' ] //************************************************** //[ 'Account', 'Account1', 'Account2', 'Account3' ] // console.log(Object.entries(sts)) //[ // [ 'UserId', 'AAAAAanbc:botocore-session' ], // [ 'Account', '123456789012' ], // [ // 'Arn', // 'arn:aws:sts::123456789012:assumed-role/abc' // ], // [ 'Account1', '123456789012' ], // [ 'Account2', '123456789012' ], // [ 'Account3', '123456789012' ] //]