Objective: Clean messy text data using expressions so the email and role fields become neat and consistent.
- Nodes Used:
When clicking "Execute Workflow" → Create Messy Data → Clean Data (Expression)
- Concept: Data cleaning with expressions using
$json, toLowerCase() and trim().
- Exercise Steps:
- [ ] Create a new workflow named
Lab 3 - Data Transformer.
- [ ] Add a Manual Trigger node and rename it to
When clicking "Execute Workflow".
- [ ] Add a Set node called
Create Messy Data and add:
Email = STUDENT@GMAIL.COM
Role = admin (with spaces before and after)
- [ ] Add another Set node called
Clean Data (Expression).
- [ ] In
Clean Data (Expression) add:
Clean_Email as an expression {{ $json.Email.toLowerCase() }}
Clean_Role as an expression {{ $json.Role.trim() }}
- [ ] Execute the workflow and compare the output of
Create Messy Data and Clean Data (Expression) to see the before and after.
- [ ] Optional for trainers: add a Sticky Note called
Instructions to remind yourself to demonstrate drag and drop into the Expression Editor before adding .toLowerCase() and .trim().

{
"nodes": [
{
"parameters": {},
"id": "159d53e0-c742-4fd3-a163-c924b21266d0",
"name": "When clicking \\"Execute Workflow\\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-304,
32
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "messy-email",
"name": "Email",
"value": "STUDENT@GMAIL.COM",
"type": "string"
},
{
"id": "messy-role",
"name": "Role",
"value": " admin ",
"type": "string"
}
]
},
"options": {}
},
"id": "1a4d3fed-9a50-44ee-8ba7-46daecac3df4",
"name": "Create Messy Data",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-80,
32
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "clean-email",
"name": "Clean_Email",
"value": "={{ $json.Email.toLowerCase() }}",
"type": "string"
},
{
"id": "clean-role",
"name": "Clean_Role",
"value": "={{ $json.Role.trim() }}",
"type": "string"
}
]
},
"options": {}
},
"id": "d49eec3a-e828-4956-b8e5-dc8e28d50e33",
"name": "Clean Data (Expression)",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
128,
32
]
},
{
"parameters": {
"content": "## Lab 3: Data transformer (expressions)\\n1. **Create Messy Data:** Simulates bad data entry (Caps, Spaces).\\n2. **Clean Data:** Uses Expressions.",
"height": 452,
"width": 780,
"color": 5
},
"id": "dd58e9a7-7a1c-4f1d-9bd5-c9bf4d04507f",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-432,
-160
],
"name": "Instructions"
}
],
"connections": {
"When clicking \\"Execute Workflow\\"": {
"main": [
[
{
"node": "Create Messy Data",
"type": "main",
"index": 0
}
]
]
},
"Create Messy Data": {
"main": [
[
{
"node": "Clean Data (Expression)",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "82cc682d3f33add4f11a78e1f29750bf4ba4e425478ba4b17330f9bf15960ec6"
}
}