How to move your code from the DataWeave Playground to Visual Studio Code
If you will be working on bigger payloads or simply want to work locally, it's recommended to use Visual Studio Code.


If you’re not familiar with the online DataWeave Playground yet, this is an online tool that you can access from your browser to develop DataWeave code without having to open Anypoint Studio. It is mainly recommended for training purposes because of its limitations - since it’s running from your browser, it’s limited to the amount of memory allocated in your browser. There is a workaround to run it locally with the Docker image (see How to run locally the DataWeave Playground Docker Image) but this image might stop being supported in the future. That’s why it’s best to start using Visual Studio Code if you want to develop more complex code and need more performance for bigger payloads.
Here’s a video to complement your learnings from this article:
Advantages
Here are a few advantages of using the DataWeave extension for Visual Studio Code instead of the DataWeave Playground (there are more, but these seemed more important for now):
- Handle bigger payloads
- Get code suggestions
- Create unit tests for your code
- Create documentation for your code
- Debug your scripts
Install the extension on VSCode
Before starting, make sure your extension on VSCode has been correctly installed. You can follow the next steps or see a detailed guide here: Getting started with the DataWeave extension for Visual Studio Code.
- Install Visual Studio Code.
- Install Java 8 and Maven version 3.6.3 or higher.
- Install the DataWeave extension for Visual Studio Code.
And that’s it!
Export the code from the Playground
We are assuming you already have some code going on in the DataWeave Playground. If this is not the case, you can simply open the Playground and use the sample code that is automatically generated.
- From the DataWeave Playground, click on the Export button at the top.

-
This will download a
.zipfile to your computer. -
Extract the contents of the
.zipfile. This root folder is the one you’ll refer to from VSCode. It contains apom.xmlfile and asrcfolder. -
Open VSCode and select File > Open Folder

-
Select the root folder from step 3.
-
You should now have a structure like the following one.

Configure your layout
- You can open both files (
payload.jsonandmain.dwl) and drag-and-drop them to where you want them to be. This will give you a similar layout as the Playground.

- You can click on the Explorer button on the far left if you want to minimize that section.

- Click on the
main.dwlwindow and click on the Run Preview button to see the output.

- Success!

Note
If you don’t get the correct output, make sure you installed Java 8 and the appropriate version of Maven, as well as the latest version of VSCode.
Enable AutoPreview
If you don’t change the AutoPreview settings, you’ll have to click on the Run Preview button every time you make a change to the script or the payload. This is useful if you want to save resources and only run the code when you need to update the preview.
If you want to enable AutoPreview so it updates automatically when you make changes to the script (as it currently does in the DataWeave Playground), simply:
- Open the
main.dwlfile - Right-click on the window
- Select DataWeave: Enable AutoPreview

That’s it! You can disable it again if you want using the Disable button :)
More resources
As mentioned before, there are a lot more advantages to using the VSCode extension that we didn’t list here. Check out the following resources for more information:
- DataWeave landing page
- [Developer tutorial] Getting started with the DataWeave extension for Visual Studio Code
- [Developer tutorial] Getting started with DataWeave libraries in Anypoint Exchange
- [Short video tutorial] How to export a script from the DataWeave Playground to Visual Studio Code
- [Twitch live stream] Exploring products: DataWeave extension for VSCode
FAQs
Frequently asked questions about this post.
-
Why should I move from the DataWeave Playground to Visual Studio Code?
The Playground runs in your browser, so it's limited to the amount of memory allocated in your browser and is mainly recommended for training purposes. Visual Studio Code is recommended when you want to develop more complex code and need more performance for bigger payloads.
-
What are the advantages of the DataWeave extension for VSCode over the Playground?
The post lists handling bigger payloads, getting code suggestions, creating unit tests for your code, creating documentation for your code, and debugging your scripts, noting there are more advantages that weren't listed.
-
What do I need to install before using the DataWeave extension?
Install Visual Studio Code, then install Java 8 and Maven version 3.6.3 or higher, and finally install the DataWeave extension for Visual Studio Code from the marketplace.
-
How do I export my code from the DataWeave Playground?
From the DataWeave Playground, click the Export button at the top, which downloads a
.zipfile to your computer; extract its contents, and that root folder (containing apom.xmlfile and asrcfolder) is the one you'll open from VSCode via File > Open Folder. -
How do I enable AutoPreview so the output updates automatically?
Without changing the AutoPreview settings you have to click the Run Preview button every time you change the script or payload. To have it update automatically like the Playground does, open the
main.dwlfile, right-click on the window, and select DataWeave: Enable AutoPreview; you can disable it again later with the Disable button. -
What should I check if I don't get the correct output?
Make sure you installed Java 8 and the appropriate version of Maven, as well as the latest version of VSCode.