Contact Free trial Login

Mule Transformers

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

transformerIn a Mule flow, a Transformer prepares a message for further processing by enhancing or altering the contents of the message properties, variables, or payload. Data transformation is one of the most powerful functionalities of Mule: rather than spending a lot of time building a customized connection between resources or processors, you can just use a pre-built transformer to perform a standard data conversion. For example, if the message source in a flow receives data in XML format, but a downstream message processor expects a Java object, you can use an XML-to-Object transformer to convert the format of the message payload.

Transformer Library

Out of the box, Mule provides a set of standard transformers to handle the most common data transformation scenarios. Typically, these elements require minimal configuration so as to facilitate quick construction of applications that must juggle different data formats between resources and processors. If Mule doesn’t have the particular transformer you need, you can arrange several transformers in a sequence to achieve the output you need. For example, if you need to implement an A-to-C transformation but no such transformer exists, you can arrange a sequence – A-to-B, B-to-C – which effectively simulates an A-to-C transformer. For example, to convert XML to JSON, use an XML-to-Object transformer followed by an Object-to-JSON transformer.

Transformers in Mule fall into one of several categories, described in the table below.

Transformers Category Description Example Transformers

Java Object

This category contains the bulk of the Mule transformers. Each transformer in this group changes a Java object into another Java object, a Java object into a non-Java data type (such as an HTTP request), or vice versa.



This group of transformers modifies messages by adding to, deleting from, or converting a message payload.

Append String
Parse Template


These transformers change SAP objects (JCo functions or IDoc documents) into XML representations, or vice versa.

XML-to-Function (BAPI)


This type of transformer utilizes a custom script to perform the transformation. If you can’t find the transformer you need in the above-listed categories, you use one of these transformers to implement a custom script to perform the transformation. Just add one of these to your flow, then write a script in your favorite language to convert data as needed.


Properties, Variables, and Attachments

Rather than acting upon the message payload, these transformers add, remove, or copy properties, variables, and attachments on the message. This group of message processors doesn’t so much transform as manipulate or enrich the contents of the message header.

Session Variable

Anypoint DataMapper Transformer

Beyond transformation, there is one type of message processor in Mule that both converts and maps data: the Anypoint DataMapper Transformer. In addition to transforming data from one format to another, DataMapper can map an input field, such as last_name, to a different output field, such as family_name (see image below). Even better, it can map multiple fields, such as title, first_name, and last_name, to a composite output field such as full_name. It can retrieve session state information in a message to facilitate conditional message routing, it can use Mule expression evaluation to facilitate conditional value recalculation, it can even look up information in tables or other flows. Read more about it in the DataMapper User Guide.

datamapper 1

DataMapper Transformer Example

STUDIO Visual Editor


XML Editor or Standalone

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:data-mapper="" xmlns:sfdc="" xmlns:file="" xmlns:tracking="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation="">

    <sfdc:config name="Salesforce" username="" password="password" securityToken="8f9sFSD97jwifD7489df4LUU335" doc:name="Salesforce">
        <sfdc:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>

    <data-mapper:config name="datamapper_grf" transformationGraphPath="datamapper.grf" doc:name="DataMapper"/>

    <flow name="Contacts_to_SFDC" doc:name="Contacts_to_SFDC" doc:description="Upload a csv file of contact information into Salesforce as new contacts.">
        <file:inbound-endpoint path="src/test/resources/input" moveToDirectory="src/test/resources/output" pollingFrequency="10000" responseTimeout="10000" doc:name="File Input"/>
        <data-mapper:transform config-ref="datamapper_grf" doc:name="DataMapper"/>
        <sfdc:create config-ref="Salesforce" type="Contact" doc:name="Salesforce">
            <sfdc:objects ref="#[payload]"/>


See Also

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub