Transform Your Data with Simple Function Nodes
detail.loadingPreview
Effortlessly manipulate and structure your data with n8n's powerful Function nodes. This workflow demonstrates how to generate mock data and then transform it into a more usable format with simple JavaScript.
About This Workflow
This n8n workflow showcases the fundamental power of JavaScript within the platform to manipulate data. It begins with a 'Mock Data' node, which generates a simple array of strings. This initial output is then fed into a 'Function' node. Inside this node, a JavaScript map function iterates through the incoming data, wrapping each individual item into a new JSON object with a 'data' key. This process is ideal for restructuring data on the fly, preparing it for subsequent steps in your automation, or for testing purposes. It highlights how n8n allows for custom logic to be integrated seamlessly into your workflows.
Key Features
- Custom Data Generation: Easily create mock or placeholder data for testing and development.
- JavaScript-Powered Transformation: Leverage the flexibility of JavaScript to reshape your data as needed.
- Data Structuring: Convert simple arrays into more complex JSON objects for further processing.
- Seamless Node Integration: Connect and pass data between nodes effortlessly within the n8n canvas.
How To Use
- Add 'Mock Data' Node: Select the 'Function' node type and name it 'Mock Data'. In the 'Function Code' parameter, enter
return [{json:["item-1", "item-2", "item-3", "item-4"]}];to generate a sample array. - Add 'Function' Node: Add another 'Function' node and name it 'Function'. In the 'Function Code' parameter, paste the following JavaScript:
return items[0].json.map(item => { return { json: { data:item } }; }); - Connect Nodes: Draw a connection from the 'Mock Data' node's output to the 'Function' node's input.
- Execute Workflow: Run the workflow to see the transformed data outputted by the 'Function' node.
Apps Used
Workflow JSON
{
"id": "1e1719e0-7331-40cd-b232-d6bbfc92a2d5",
"name": "Transform Your Data with Simple Function Nodes",
"nodes": 6,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 1e1719e0-7331...
About the Author
N8N_Community_Pick
Curator
Hand-picked high quality workflows from the global community.
Statistics
Related Workflows
Discover more workflows you might like
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.