---
schema_version: "1"
id: da0345ddbf1bb17de41334a21d831bafd6ec54339cc72bc6b4aaa1a7c92edbe7
title: DataWeave in Apex
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/DataWeaveInApex.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/DataWeaveInApex.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 97a9dd93ebb806928a55c93f8976b05a38be2ab7e412b129c8f08850eacb9a95
description: DataWeave in Apex uses the Mulesoft DataWeave library to read and parse data from one format, transform it, and export it in a different format. You can create DataWeave scripts as metadata and invoke them directly from Apex. Like Apex, DataWeave scripts are run within Salesforce application servers, enforcing the same heap and CPU limits on the executing code.
---
# DataWeave in Apex

DataWeave in Apex uses the Mulesoft DataWeave library to read and parse data from one format, transform it, and export it in a different format. You can create DataWeave scripts as metadata and invoke them directly from Apex. Like Apex, DataWeave scripts are run within Salesforce application servers, enforcing the same heap and CPU limits on the executing code.

Enterprise applications often require transformation of data between formats such as CSV, JSON, XML, and Apex objects. DataWeave in Apex complements native Apex support for JSON and XML processing, and makes data transformation easier to code, more scalable, and efficient. Apex developers can focus more on solving business problems and less on addressing the specifics of file formats.

DataWeave is the MuleSoft expression language for accessing, parsing, and transforming data that travels through a Mule application. For detailed information, see [DataWeave Overview](https://docs.mulesoft.com/mule-runtime/4.3/dataweave "HTML (New Window)"). 

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/images/icon_note.png)

#### Note

You don’t have to be a MuleSoft customer or have any specific Salesforce license to use DataWeave in Apex.

The following are some use-cases for DataWeave in Apex.

- Serializing Apex objects with custom date formats
- Serializing and deserializing JSON with Apex reserved keywords
- Performing custom transformations like removing or adding namespaces or removing \_\_c suffixes
- Parsing and transforming RFC 4180-compliant CSV (Comma-Separated Values) data

You can create a listview for DataWeave resources in your org and view deployed DataWeave scripts within your namespace. From Setup, in the Quick Find box, enter DataWeave, and then select **DataWeave Resources**. Select the fields that you want to monitor, such as the DataWeave Resource ID, Name, Namespace Prefix, and API Version.

- **[Implementing DataWeave in Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/DataWeaveInApex_impl.htm)**  
    Create DataWeave scripts as metadata and invoke them directly from Apex. Use class methods and exceptions in the DataWeave namespace to load and execute the scripts.
- **[Examples of DataWeave in Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/DataWeaveInApex_UseCase.htm)**  
    Here are code samples that demonstrate DataWeave in Apex.
- **[Limitations of DataWeave in Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/DataWeaveInApex_limitations.htm)**  
    DataWeave in Apex has these limitations.

#### See Also

- [_Apex Reference Guide_: DataWeave Namespace](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_namespace_dataweave.htm "Apex Reference Guide: DataWeave Namespace - HTML (New Window)")
- [_Metadata API Developer Guide_: DataWeaveResource](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_dataweaveresource.htm "Metadata API Developer Guide: DataWeaveResource - HTML (New Window)")
- [_Salesforce DX Developer Guide_: DataWeaveResource](https://developer.salesforce.com/docs/atlas.en-us.264.0.sfdx_dev.meta/sfdx_dev/packaging_packageable_components.htm#mdc_dataweaveresource "Salesforce DX Developer Guide: DataWeaveResource - HTML (New Window)")