Best Practices for Clean Workflows
Document à appliquer et à faire évoluer
Create clean, maintainable, and efficient workflows in N8N. Following these best practices will
help you build automations that are easier to understand, debug, and modify.
Node Naming and Organization
Use Descriptive Names
● Give each node a clear, descriptive name that explains its purpose
● Examples:
○ "Search for Name Record" instead of "Airtable Search Records"
○ "Remove HTML Formatting" instead of "Code"
○ "Generate Icebreaker" instead of "AI Agent"
○ "Send Message to User" instead of "Gmail Send Message"
Organize Visually
● Use the "Tidy up workflow" option (right-click on canvas) to automatically arrange nodes
linearly
● Group related nodes visually by function or purpose
Add Sticky Notes
● Right-click on canvas and select "Add sticky note"
● Use markdown formatting (# for headers) to make notes stand out
● Color-code notes for different workflow sections
● Examples:
○ Blue section for "Search Phase"
○ Red section for "Content Creation"
○ Green section for "Message Delivery"
Modular Workflow Design
Break complex workflows into smaller, reusable sub-workflows:
Benefits of Sub-workflows
● Easier to maintain and debug
● Promotes reusability
● Improves organization and readability
● Simplifies testing
Creating a Sub-workflow
1. Create a new workflow for the sub-process
2. Add a "When Executed by Another Workflow" trigger node
3. Configure data acceptance (accept all data or define specific fields)
4. Build the sub-workflow logic
5. In the main workflow, use "Execute a Sub-workflow" node
6. Select the sub-workflow to call
7. Configure "Wait for the sub-workflow to complete" if needed
Data Passing Between Workflows
● Use $json references to pass specific data to sub-workflows
● Make sure variable names match between parent and child workflows
Workflow Templates and Reuse
Copy and Paste
● Select multiple nodes by clicking and dragging
● Use Ctrl+C/Ctrl+V to copy/paste between workflows
Export and Import
● Download workflows as JSON files (Download button)
● Import workflows from:
○ Local files (Import from file)
○ URLs (Import from URL)
Pinning Data for Debugging
Pinning data allows you to "freeze" the output of a node, making debugging faster and more
efficient:
How to Pin Data
● Click on a node and press "P" key
● Or right-click and select "Pin"
● A pin icon will appear on the node
Benefits of Pinning
● Avoid unnecessary API calls during testing
● Save time by not executing the entire workflow repeatedly
● Test downstream nodes with consistent data
Editing Pinned Data
● Click the pencil icon on a pinned node
● Modify values to test different scenarios
● Save changes and continue testing
Performance Considerations
Parallel vs. Sequential Execution
● N8N can run independent nodes in parallel
● However, execution order isn't always guaranteed
Handling Dependencies Between Parallel Branches
● Use a Merge node to ensure all parallel branches complete before continuing
● Connect all branches as inputs to the Merge node
● The workflow will continue only after all inputs are processed
Example Problem
● If Node C depends on data from both Node A and Node B
● Instead of connecting A → C and B → C directly
● Use A → Merge ← B → C to ensure all data is available
Avoiding Unnecessary Complexity
● Keep workflows as simple as possible
● Avoid deeply nested loops when possible
● Break complex processes into sub-workflows
● Test thoroughly when using complex logic
Credential Management
Storing API Keys and Credentials
● Avoid hardcoding credentials in nodes
● Use N8N's credential management system
Types of Credentials
1. Predefined Credential Types
○ Choose from N8N's list of integrated services
○ Fill in required authentication details once
2. Generic Credential Types
○ Header Auth: For API key in header
○ Create reusable credentials with service name
○ Select saved credentials when configuring nodes
Benefits
● Improved security
● Easier maintenance
● Reusability across workflows
Final Recommendations
● Review workflows regularly for clarity and efficiency
● Document complex processes with sticky notes
● Test workflows thoroughly, especially error handling
● Maintain consistent naming conventions
● Use sub-workflows for complex processes
Remember: A clean workflow saves time in the long run, especially when
troubleshooting or making changes.