This workflow template takes a JSON object and a row index and returns exactly one key–value pair at that index. It is useful when you need to pick a single entry from structured JSON data and pass it to downstream nodes in n8n.
- Developers working with API responses
- Makers building quick automations
- Analysts extracting specific values from JSON
- Anyone needing lightweight JSON manipulation without complex logic
- Manual Trigger starts the workflow.
- Set – Input JSON node contains:
myData: JSON object with key–value pairsrowIndex: zero‑based index of the pair to extract
- Code (Python) node iterates through the object and selects the key–value pair at the specified index.
- Set – Key node outputs the extracted key.
- Set – Value node outputs the extracted value.
- The extracted key and value are available for further processing.
- Import the workflow into your n8n account.
- Open the Input JSON node and replace the sample JSON:
{
"myData": {
"name": "Alice",
"age": "30",
"city": "Paris"
},
"rowIndex": "1"
}- Click Execute workflow.
- Check the output of the Key and Value nodes.
- n8n account (cloud or self‑hosted)
- Code node enabled (Python)
- Valid JSON object as input
- Zero‑based integer index (
rowIndex)
- Pick by key instead of index: Modify the Code node to directly reference a key name.
- Nested JSON support: Add logic to flatten or traverse nested objects.
- Output format: Return a combined object
{ key, value }instead of separate fields. - Validation: Add guards for missing keys or invalid index values.
- Replace Manual Trigger with Webhook to accept live JSON payloads.
- Log extracted values into Google Sheets or a database.
- Add conditional routing based on extracted key or value.
- Chain with transformation workflows.
- Extract a specific field from an API response.
- Pick one answer from a form submission.
- Read configuration values dynamically.
- Control workflow routing using extracted JSON data.
| Issue | Possible Cause | Solution |
|---|---|---|
| Index out of range | Invalid rowIndex |
Ensure index is within bounds |
| Wrong value extracted | JSON key order differs | Use key‑based selection |
| Empty output | myData is empty or invalid |
Validate JSON input |
| Code node error | Python disabled | Enable Python or convert to JS |
| Unexpected type | Non‑string value | Cast value before use |
If you need:
- Key‑based extraction
- Nested JSON handling
- Webhook‑based input
- Advanced validation or logging
Contact WeblineIndia for workflow customization and support.