Transform CSV to JSON
n8n-nodes-base.code
Convert CSV data to structured JSON format with field mapping and data validation. Essential for data processing pipelines.
π‘ Use Cases
- Import CSV files into your system
- Clean and structure legacy data
- Prepare data for API consumption
π Node Configuration
{
"nodes": [
{
"parameters": {
"content": "## π CSV to JSON Transform\n\n**Usage:**\nConverts CSV data to JSON format for easy processing.\n\n**Required Input:**\n- `data`: CSV string with headers in first row\n\n**Setup:**\n1. No credentials needed\n2. Pass CSV data with headers\n3. Code node transforms to JSON array\n\n**Output:**\nArray of JSON objects with headers as keys",
"height": 238,
"width": 389,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"position": [
96,
332
],
"typeVersion": 1,
"id": "sticky-f6e5d4c3-b2a1-4d5e-8c7b-9a0f1e2d3c4b",
"name": "Sticky Note"
},
{
"parameters": {
"mode": "runOnceForAllItems",
"jsCode": "// Transform CSV data to JSON\nconst csvData = $input.first().json.data;\nconst lines = csvData.split('\\n');\nconst headers = lines[0].split(',').map(h => h.trim());\n\nconst results = [];\n\nfor (let i = 1; i < lines.length; i++) {\n if (lines[i].trim()) {\n const values = lines[i].split(',').map(v => v.trim());\n const obj = {};\n \n headers.forEach((header, index) => {\n obj[header] = values[index] || '';\n });\n \n results.push(obj);\n }\n}\n\nreturn results.map(item => ({ json: item }));"
},
"id": "f6e5d4c3-b2a1-4d5e-8c7b-9a0f1e2d3c4b",
"name": "CSV to JSON Transform",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
368,
400
]
}
],
"connections": {},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "751aeba95f3d1aebe5a6ebe9d20293dd6c0f61b00ef369c580f0dc54913f5fcb"
}
}
BuildShip configuration not available for this node.
Make.com configuration not available for this node.