Overview
This node, named "Split," routes incoming items to different outputs based on weighted probabilities defined by the user. It is useful when you want to distribute data or tasks unevenly across multiple branches in a workflow, according to specified weights.
For example, if you have three outputs labeled A, B, and C with weights 50, 30, and 20 respectively, approximately 50% of the input items will be routed to output A, 30% to output B, and 20% to output C. This can be used for load balancing, A/B testing, or splitting data streams proportionally.
Properties
| Name | Meaning |
|---|---|
| Input Mode | Choose how to enter weights: - Form (Recommended): Enter name/weight pairs via UI. - JSON (Advanced): Paste a JSON array of objects with name and weight fields. |
| Weights (Form) | Add one or more weight entries, each with: - Name: Label for this weight/output. - Weight: Numeric value โฅ 0 representing the relative probability. |
| Weights JSON | Alternative to form input: paste a JSON array like [{"name":"A","weight":50}, ...]. Must be valid JSON. |
Output
The node outputs multiple branches corresponding to the defined weights. Each output branch contains the subset of input items routed to it based on the weighted random selection.
- The output is an array of arrays, where each inner array corresponds to one output branch.
- Each item in the output retains its original data and includes a
pairedItemproperty indicating its original index. - The number of outputs equals the number of weight entries.
- No binary data is produced by this node.
Dependencies
- No external services or API keys are required.
- The node relies on standard JavaScript functionality and n8n's core framework.
- No special environment variables or credentials are needed.
Troubleshooting
- Invalid JSON format for weights: If using JSON input mode, ensure the pasted JSON is valid and follows the expected structure (an array of objects with
nameandweight). - At least one weight entry is required: The node throws an error if no weights are provided.
- Total weight must be greater than 0: All weights combined must sum to a positive number; otherwise, routing cannot be performed.
- If items do not appear in expected proportions, remember that the distribution is probabilistic and may vary slightly with small numbers of items.
Links and References
- n8n Documentation
- JavaScript Math.random() โ Used internally for weighted random selection