AutomationFlowsData & Sheets › Manual CSV to JSON Converter

Manual CSV to JSON Converter

Original n8n title: Fluxo 1

Fluxo 1. Uses mongoDb, readWriteFile. Event-driven trigger; 5 nodes.

Event trigger★★★★☆ complexity5 nodesMongoDBRead Write File
Data & Sheets 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
{
  "name": "Fluxo 1",
  "nodes": [
    {
      "parameters": {
        "operation": "insert",
        "collection": "leads",
        "fields": "first_name,last_name,phone,cpf,age,released_value,created_at",
        "options": {}
      },
      "id": "f8270f2c-df87-4403-b58a-d2f9450c176c",
      "name": "MongoDB",
      "type": "n8n-nodes-base.mongoDb",
      "typeVersion": 1.1,
      "position": [
        1600,
        360
      ],
      "credentials": {
        "mongoDb": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "id": "b954a2f1-b940-4419-862f-1344c5c7a41f",
      "name": "Start the Test",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        780,
        360
      ]
    },
    {
      "parameters": {
        "jsCode": "return items.map(item => {\n  let age = null;\n  if (item.json && item.json.birthdate && typeof item.json.birthdate === \"string\") {\n    try {\n      const [day, month, year] = item.json.birthdate.split('/');\n      const birthDate = new Date(`${year}-${month}-${day}`);\n      if (!isNaN(birthDate) && birthDate <= new Date()) {\n        age = Math.abs(new Date().getUTCFullYear() - birthDate.getUTCFullYear());\n      }\n    } catch (error) {\n      console.log(\"Erro ao processar birthdate:\", error);\n    }\n  }\n\n  let firstName = \"N/A\";\n  let lastName = \"N/A\";\n  if (item.json && item.json.name && typeof item.json.name === \"string\") {\n    const nameParts = item.json.name.trim().split(/\\s+/);\n    firstName = nameParts[0] || \"N/A\";\n    lastName = nameParts.slice(1).join(' ') || \"N/A\";\n  }\n\n  let cpf = \"00000000000\";\n  if (item.json && item.json.cpf && /^[0-9]{11}$/.test(item.json.cpf)) {\n    cpf = item.json.cpf;\n  } else if (item.json && item.json.cpf) {\n    cpf = item.json.cpf.replace(/\\D/g, '').padStart(11, '0');\n  }\n\n  let releasedValue = 0.0;\n  if (item.json && item.json.released_value !== undefined && !isNaN(item.json.released_value)) {\n  \n    releasedValue = parseFloat(item.json.released_value);\n  \n    if (Number.isInteger(releasedValue)) {\n      releasedValue = releasedValue + 0.0; \n    }\n\n    releasedValue = Math.round(releasedValue * 100) / 100;\n}\n\n  // Objeto formatado para o MongoDB\n  return {\n    json: {\n      first_name: firstName,\n      last_name: lastName,\n      phone: formatPhone(item.json.phone || \"\"),\n      cpf: cpf,\n      age: age !== null ? parseInt(age, 10) : 0,\n      released_value: releasedValue,\n      created_at: new Date(),\n    },\n  };\n});\n\n// Fun\u00e7\u00e3o para formatar o telefone\nfunction formatPhone(phone) {\n  phone = phone.replace(/\\D/g, '');\n  if (!phone.startsWith('55')) phone = '55' + phone;\n  if (phone.length === 12 && phone[4] !== '9') {\n    phone = phone.slice(0, 4) + '9' + phone.slice(4);\n  }\n  return phone;\n}"
      },
      "id": "707cbef6-26d2-414b-bd6d-730f6caa7c99",
      "name": "Formatting",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1400,
        360
      ]
    },
    {
      "parameters": {
        "fileSelector": "/home/city/Documentos/testekonsi/base_de_dados_prosel_dev_junior.csv",
        "options": {}
      },
      "id": "af539b1f-2e68-4ff8-beb1-f1056c62ddbd",
      "name": "File_csv_base",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        1000,
        360
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "d4cdbae0-ee84-40d0-bc8c-182516caba98",
      "name": "Convert_to_JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1200,
        360
      ]
    }
  ],
  "connections": {
    "Start the Test": {
      "main": [
        [
          {
            "node": "File_csv_base",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Formatting": {
      "main": [
        [
          {
            "node": "MongoDB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File_csv_base": {
      "main": [
        [
          {
            "node": "Convert_to_JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert_to_JSON": {
      "main": [
        [
          {
            "node": "Formatting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0ef6fee9-648c-421d-8874-de70cb6fc8cc",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "5XsU87biWSoz76Cl",
  "tags": []
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

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

About this workflow

Fluxo 1. Uses mongoDb, readWriteFile. Event-driven trigger; 5 nodes.

Source: https://github.com/BrenoCidade/Desafio_Konsi/blob/afc8ce60609d7e719264d48e78876138eb218652/Fluxo_1.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

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

Data & Sheets

Components. Uses postgres, readWriteFile. Event-driven trigger; 42 nodes.

Postgres, Read Write File
Data & Sheets

This template demonstrates how to build a low-code, AI-powered data analysis workflow in n8n. It enables you to connect to various data sources (such as MySQL, Google Sheets, or local files), process

MySQL, Google Sheets, Read Write File +2
Data & Sheets

This n8n template provides a production-ready, memory-safe pipeline for ingesting large Hugging Face datasets into MongoDB using batch pagination. It is designed as a reusable data ingestion layer for

Execute Workflow Trigger, HTTP Request, MongoDB
Data & Sheets

This n8n workflow securely processes contact form submissions by validating user input, formatting the data, and storing it in a MongoDB database. The flow ensures data consistency, prevents unsafe en

Form Trigger, MongoDB, Form
Data & Sheets

My Workflow. Uses start, mongoDb, httpRequest, localFileTrigger. Event-driven trigger; 7 nodes.

Start, MongoDB, HTTP Request +1