Is there any way to get the name of a key from its value?

Hey!
I have a key value in the input, but its name is not known.

You can do something like this:

const searchValue = 'value2';

let foundColum = '';
items.forEach(item => {
  foundColum = '';
  for (const key in item.json) {
    if (item.json[key] === searchValue) {
      foundColum = key;
      break;
    }
  }
  item.json.foundColum = foundColum;
});

return items;

Here an example workflow:

{
  "nodes": [
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      col1: 'value1',\n      col2: 'value2',\n      col3: 'value3',\n    }\n  }\n];"
      },
      "name": "Mock Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const searchValue = 'value2';\n\nlet foundColum = '';\nitems.forEach(item => {\n  foundColum = '';\n  for (const key in item.json) {\n    if (item.json[key] === searchValue) {\n      foundColum = key;\n      break;\n    }\n  }\n  item.json.foundColum = foundColum;\n});\n\nreturn items;"
      },
      "name": "Find Column",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Mock Data": {
      "main": [
        [
          {
            "node": "Find Column",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks Jan!