AutomationFlowsGeneral › Extract Key-Value Pairs from JSON

Extract Key-Value Pairs from JSON

Original n8n title: 📄 Extract Key Value From JSON - N8n Workflow

📄 Extract Key Value from JSON - n8n Workflow. Event-driven trigger; 5 nodes.

Event trigger★★★★☆ complexity5 nodes
General Trigger: Event Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "LSZHMsAomkKlMfYR",
  "name": "\ud83d\udcc4 Extract Key Value from JSON - n8n Workflow",
  "tags": [],
  "nodes": [
    {
      "id": "9ef4197b-17d8-42aa-b771-2b151763298a",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -40,
        -20
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7fa816d2-60e4-42bc-9803-3e49ceb7a4ab",
      "name": "Input JSON Node",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        -20
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"myData\": {\n    \"name\": \"Alice\",\n    \"age\": \"30\",\n    \"city\": \"Paris\"\n  },\n  \"rowIndex\": \"1\"\n}\n\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "c2a948b4-65b5-490d-8e4c-cdb6b39ad70e",
      "name": "Find Key-Value Pair",
      "type": "n8n-nodes-base.code",
      "position": [
        340,
        -20
      ],
      "parameters": {
        "language": "python",
        "pythonCode": "import json\nans=[]\nind = (_input.first().json.rowIndex)\nind=int(ind)\n\nfor i in _input.first().json.myData:\n  if ind==0:\n    ans.append(i)\n    ans.append(_input.first().json.myData[i])\n    break\n  ind=ind-1\n\n# Return in valid n8n format\nreturn [{\"json\": {\"result\": ans}}]\n\n\n\n\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "c2f94136-8254-44b6-abe2-39caa814b036",
      "name": "Key",
      "type": "n8n-nodes-base.set",
      "position": [
        600,
        -140
      ],
      "parameters": {
        "options": {
          "dotNotation": false,
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "243bbcc4-ff8a-4af5-b80b-96c524d33118",
              "name": "result",
              "type": "array",
              "value": "={{ $json.result[0] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1e6f42da-e376-463b-acc5-37a5454d55d3",
      "name": "Value",
      "type": "n8n-nodes-base.set",
      "position": [
        600,
        120
      ],
      "parameters": {
        "options": {
          "dotNotation": false,
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "5b20ed91-93b0-45b4-b555-5d7a3cff672e",
              "name": "result[1]",
              "type": "string",
              "value": "={{ $json.result[1] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "fc8d479a-c821-44d1-9b46-f617cbfb5e25",
  "connections": {
    "Key": {
      "main": [
        []
      ]
    },
    "Input JSON Node": {
      "main": [
        [
          {
            "node": "Find Key-Value Pair",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Key-Value Pair": {
      "main": [
        [
          {
            "node": "Key",
            "type": "main",
            "index": 0
          },
          {
            "node": "Value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Input JSON Node",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

📄 Extract Key Value from JSON - n8n Workflow. Event-driven trigger; 5 nodes.

Source: https://github.com/weblineindia/n8n-JSON-data-utility-extract-key-value-pairs-by-index/blob/main/main.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Read Binary File, Write Binary File, Execute Command
General

A modular schema checker that returns detailed error messages on validation failure.

Execute Workflow Trigger
General

Validate Totp Token Without Creating A Credential. Uses manualTrigger, stickyNote. Event-driven trigger; 5 nodes.

General

v1 helper - Find params with affected expressions. Uses manualTrigger, n8n, stickyNote. Event-driven trigger; 4 nodes.

n8n
General

ℹ️ This workflow is to be run after upgrading to n8n v1.

n8n