DataWeave Playground: 10 Transformations to Practise
Learn how to use the DataWeave playground, then practise 10 copy-paste transformations with input, script and output, tied to MuleSoft interview tasks.
28 Oct 2026·10 min read·Salesforce AI
Open the DataWeave playground, paste ten lines of JSON, and you can see a transformation work or fail in about five seconds. That feedback loop is the fastest way I know to get good at MuleSoft's transformation language, and most learners waste it.
If you're a MuleSoft developer, a Salesforce developer moving into integration, or a fresher preparing for interviews, this page is the practice routine I'd follow.
Key takeaways
- The DataWeave playground is a browser tool where you paste an input payload, write a script and see the output, with no Mule project to set up.
- You get good by predicting the output before you run the script, not by copying solved answers.
- Ten small transformations (map, filter, groupBy, reduce, mapObject, XML selectors, default, dates, flatMap and format conversion) cover most real project and interview tasks.
- Never paste real client data into any online playground. Invent sample data instead.
What the DataWeave playground is for (and what it isn't)
The DataWeave playground lets you build mock transformations in your browser from an input payload, so you can practise the language without running a Mule application.
That is how MuleSoft describes it on the DataWeave Playground and interactive tutorial page on MuleSoft's developer site. The same page notes there is a tutorial section with interactive exercises alongside the free-form editor.
What it isn't: a replacement for a real flow. In a Mule flow your script also sees things like vars and attributes, and it runs against real connectors, real errors and real volumes. In the playground you only get what you paste in.
Treat it as a gym, not the match. It teaches you to read the shape of data and write the script that reshapes it.
If you want a different environment, the official DataWeave Quickstart shows how to turn the Transform Message component in Anypoint Studio into a playground. You paste scripts into the source area and read the result in the Preview pane. The Salesforce Developers blog (6 December 2023) also walks through other ways to run DataWeave, from drag-and-drop in a Mule app to a command-line tool.
How to use the DataWeave playground, step by step
Work in a fixed loop: paste input, set its format, write the script, read the output, change one thing.
Interface labels change over time, so follow the idea rather than the exact button names.
- Open the playground from the MuleSoft Developers page linked above.
- Paste an input payload and make sure the playground knows its format (JSON, XML, CSV and so on). A wrong format is the most common reason nothing works.
- Start every script with the header. Use
%dw 2.0, then anoutputline, then---, then your expression. Mule 4 uses DataWeave 2.0, and the Quickstart is written for it. - Predict, then run. Write the expected output on paper before you hit run. If you're wrong, you've found a gap in your understanding, which is the whole point.
- Break it on purpose. Remove a field from the input, send a null, add a second record. Real payloads are never as tidy as sample data.
- Move to the tutorial section once you're comfortable.
My take: The playground's biggest risk is that it makes copying too easy. Searching for a solved answer and pasting it feels like progress, but it isn't. An interviewer will change one field in your input and ask what breaks. Predicting output first is the only habit that survives that question.
10 transformations to practise
These ten cover most of what you'll be asked in a MuleSoft interview and most of what you'll write in your first integration project.
I've picked them from the functions I'd expect any integration developer to use weekly. The ordering is a judgement, not an official curriculum.
| # | Transformation | Key idea | Where it shows up |
|---|---|---|---|
| 1 | JSON to CSV | output application/csv | Report and file exports |
| 2 | Build a new object | map | Field mapping between systems |
| 3 | Drop records | filter | Removing inactive or invalid rows |
| 4 | Bucket by key | groupBy | Regional or status summaries |
| 5 | Total a field | reduce | Order totals, "sum without a helper" |
| 6 | Rename keys | mapObject | Aligning field names across APIs |
| 7 | XML to JSON | .@attr, .*element | Legacy and SOAP-style payloads |
| 8 | Handle nulls | default | Optional fields, bad data |
| 9 | Reformat dates | as Date, as String | Date mismatches between systems |
| 10 | Flatten nested data | flatMap | Turning orders with items into rows |
The first three use this input, which mirrors the sample on the DataWeave language site:
[
{ "firstName": "John", "lastName": "Smith", "age": 45 },
{ "firstName": "Jane", "lastName": "Doe", "age": 34 }
]
1. JSON to CSV: the report export
%dw 2.0
output application/csv
---
payload
Output:
firstName,lastName,age
John,Smith,45
Jane,Doe,34
Format conversion is the smallest script in the language and one of the most asked questions. Change the output to application/xml and see what happens. XML needs a single root, so you'll hit your first error.
2. Map: build a new object per record
%dw 2.0
output application/json
---
payload map ((c) -> {
fullName: c.firstName ++ " " ++ c.lastName,
age: c.age
})
Output:
[
{ "fullName": "John Smith", "age": 45 },
{ "fullName": "Jane Doe", "age": 34 }
]
This is field mapping. Almost every project has a version of it, such as shaping an ERP record into what a Salesforce API expects.
3. Filter: keep only what matters
%dw 2.0
output application/json
---
payload filter ((c) -> c.age > 40)
Output:
[
{ "firstName": "John", "lastName": "Smith", "age": 45 }
]
Stretch: chain it, payload filter (...) map (...), and say aloud which runs first.
4. groupBy: bucket records by a key
Use this input for exercises 4 and 5:
[
{ "id": 1, "region": "North", "amount": 100 },
{ "id": 2, "region": "South", "amount": 250 },
{ "id": 3, "region": "North", "amount": 150 }
]
%dw 2.0
output application/json
---
payload groupBy ((o) -> o.region)
Output:
{
"North": [
{ "id": 1, "region": "North", "amount": 100 },
{ "id": 3, "region": "North", "amount": 150 }
],
"South": [
{ "id": 2, "region": "South", "amount": 250 }
]
}
Note that an array went in and an object came out. That change of shape is what interviewers probe.
5. reduce: total a field
%dw 2.0
output application/json
---
payload reduce ((item, acc = 0) -> acc + item.amount)
Output: 500
Stretch: combine 4, 5 and 6 to produce the total per region. It's a classic interview question because it forces you to use three functions together.
6. mapObject: rename keys
Input:
{ "firstName": "John", "lastName": "Smith" }
%dw 2.0
output application/json
---
payload mapObject ((value, key) -> {
(upper(key as String)): value
})
Output:
{ "FIRSTNAME": "John", "LASTNAME": "Smith" }
map works on arrays and mapObject works on objects. Mixing them up is the most common beginner error.
7. XML to JSON: attributes and repeated elements
Input (set the format to XML):
<order id="101">
<item sku="A1" qty="2"/>
<item sku="B7" qty="1"/>
</order>
%dw 2.0
output application/json
---
{
orderId: payload.order.@id,
items: payload.order.*item map ((i) -> {
sku: i.@sku,
qty: i.@qty as Number
})
}
Output:
{
"orderId": "101",
"items": [
{ "sku": "A1", "qty": 2 },
{ "sku": "B7", "qty": 1 }
]
}
.@ reads an attribute. .*item collects every repeated item. Without the asterisk you only get the first one.
8. default: survive missing data
Input:
{ "name": "Asha", "phone": null }
%dw 2.0
output application/json
---
{
name: payload.name,
phone: payload.phone default "N/A",
email: payload.email default "not provided"
}
Output:
{ "name": "Asha", "phone": "N/A", "email": "not provided" }
default covers both a null value and a missing field. Production data has both, so test both.
9. Dates: reformat between systems
Input:
{ "orderDate": "2026-10-17" }
%dw 2.0
output application/json
---
{
orderDate: payload.orderDate as Date {format: "yyyy-MM-dd"} as String {format: "dd/MM/yyyy"}
}
Output:
{ "orderDate": "17/10/2026" }
Date format mismatches between systems are a daily annoyance on integration projects. Learn to read the string into a Date first, then write it out in the target format.
10. flatMap: nested orders to flat rows
Input:
[
{ "orderId": 1, "items": [ { "sku": "A1" }, { "sku": "B7" } ] },
{ "orderId": 2, "items": [ { "sku": "C3" } ] }
]
%dw 2.0
output application/json
---
payload flatMap ((o) ->
o.items map ((i) -> { orderId: o.orderId, sku: i.sku })
)
Output:
[
{ "orderId": 1, "sku": "A1" },
{ "orderId": 1, "sku": "B7" },
{ "orderId": 2, "sku": "C3" }
]
Parent-child to flat rows is how you'd prepare order lines for a bulk load. Try the version with map instead of flatMap and look at the nested arrays it produces.
My take: If you can do exercise 5 stretch (total per region) with no help, you're ahead of most freshers I'd expect to meet in an interview. That's my judgement, not a measured benchmark. But the pattern is the same one behind most reporting and reconciliation scripts, and it tests thinking rather than memory.
Common mistakes in the DataWeave playground
Most playground errors come from the input, not the script.
- Wrong input format. You paste XML but leave the format as JSON.
- Broken JSON from copying. Smart quotes and stray characters from web pages or documents make valid-looking JSON invalid.
- Missing
outputline. State the output format explicitly so you know what you're producing. - Forgetting the asterisk.
payload.order.itemgives one item.payload.order.*itemgives all of them. - Trusting tidy samples. Test with nulls, empty arrays and one-record inputs.
- Using old syntax. Some tutorials are written for DataWeave 1.0. Mule 4 uses 2.0, so check the header.
- Pasting real data. Finance, candidate or client data does not belong in a browser tool you haven't vetted. Invent sample records instead. Some community-built online editors exist, and I haven't audited them. Treat anything outside MuleSoft's own pages with the same caution.
Why DataWeave still matters for your Salesforce career
Integration skill is what lets a Salesforce project talk to everything else, and clean data movement is what AI agents depend on.
That second point is my judgement, not a statistic. An agent that reads a customer record from one system and writes to another is only as reliable as the transformation between them. If you're new to this side of the platform, my guides on what Agentforce is and Salesforce jobs for freshers in 2026 show where integration skills fit. When you're ready to test yourself, try my Salesforce developer interview questions for 2026.
Want to see how I think about building integration and agent skills in a real programme? Catch one of my sessions.
Try this week:
- Do exercises 1 to 5 in the playground, writing your predicted output before each run.
- Break each script on purpose with a null, a missing field and an empty array.
- Invent a sample payload from your own project area (for example, a services company's invoice) and write three transformations on it.
- Work through one section of the official interactive tutorial and compare your approach with the MuleSoft tutorial repository.
Frequently asked questions
What is the DataWeave playground?
It's a browser-based tool where you provide an input payload, write a DataWeave script and see the transformed output. MuleSoft's developer site also pairs it with an interactive tutorial section so you can practise step by step.
Do I need Anypoint Studio to practise DataWeave?
No. The playground runs in the browser. If you do have Studio, the DataWeave Quickstart shows how to use the Transform Message component and its Preview pane as a playground too.
Which DataWeave version should I learn?
Learn DataWeave 2.0, which is what the current MuleSoft documentation uses and what Mule 4 runs. Start every script with %dw 2.0, and be careful with older tutorials written for version 1.0.
Can I paste real client data into an online playground?
I'd say no. Use invented sample data that has the same shape as your real payloads. Keep client, finance and candidate data out of any tool you haven't approved, and remember that India's DPDP Act applies to personal data.
Where can I find more DataWeave practice examples?
Start with MuleSoft's interactive tutorial. Then write your own exercises from real project problems, because those are the ones that stick.
Want to put this to work in your business?
Join one of my live sessions, or tell me what you're trying to do with AI.
Newsletter
Get the next one by email.
New writing on Salesforce AI, AI agents and the AI-Native Enterprise. Confirm by email; unsubscribe any time.
Keep reading
2 Nov 2026 · Salesforce AISalesforce Workbench: How to Use It Safely (No Undo)Salesforce Workbench explained for admins and developers: run SOQL, export data, retrieve metadata and follow the safety rules most people skip.8 min
1 Nov 2026 · Future of workSalesforce Administrator Certification: Worth It in 2026?Is the Salesforce administrator certification worth it in 2026? See the US$200 cost, exam changes, what employers want and an 8-week plan.7 min
31 Oct 2026 · Salesforce AIHow to Debug a Salesforce Flow: Fix Common ErrorsHow to debug a Salesforce Flow step by step: use debug mode, add fault paths, read debug logs and stop error emails. Fixes for the errors admins hit.10 min