---
schema_version: "1"
id: ebe1b100869285e95d82ecf46fceb0e2331ac8faa178aa11d7eb2acbf02b20a0
title: Supported Data Formats
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dataweave-formats.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dataweave-formats
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 12da79e769d52fdf4ee14e313febb7f43ec3371f080d09936e5a93f13a9475f5
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
keywords: studio, anypoint, esb, transform, transformer, format, aggregate, rename, split, filter convert, xml, json, csv, pojo, java object, metadata, dataweave, data weave, datamapper, dwl, dfl, dw, output structure, input structure, map, mapping
---

# Supported Data Formats

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

DataWeave can read and write many types of data formats, such as JSON, XML, and many others.

DataWeave supports the following formats as input and output:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>MIME Type</th><th>ID</th><th>Supported Formats</th></tr></thead><tbody><tr><td><p><code>application/avro</code></p></td><td><p><code>avro</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-avro">Avro Format</a></p></td></tr><tr><td><p><code>application/csv</code></p></td><td><p><code>csv</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-csv">CSV Format</a></p></td></tr><tr><td><p><code>application/dw</code></p></td><td><p><code>dw</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-dw">DataWeave Format (dw)</a> for testing a DataWeave expression</p></td></tr><tr><td><p><code>application/flatfile</code></p></td><td><p><code>flatfile</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-flatfile">Flat File Format</a>, <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-copybook">COBOL Copybook Format</a>, <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-fixedwidth">Fixed Width Format</a></p></td></tr><tr><td><p><code>application/java</code></p></td><td><p><code>java</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-java">Java Format</a>, <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-java#format_enum">Enum Format for Java</a></p></td></tr><tr><td><p><code>application/json</code></p></td><td><p><code>json</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-json">JSON Format</a></p></td></tr><tr><td><p><code>application/octet-stream</code></p></td><td><p><code>binary</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-binary">Binary Format</a></p></td></tr><tr><td><p><code>application/xlsx</code></p></td><td><p><code>excel</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-excel">Excel Format</a></p></td></tr><tr><td><p><code>application/xml</code></p></td><td><p><code>xml</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-xml">XML Format</a>, <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-xml#format_xml_cdata">CData Custom Type</a></p></td></tr><tr><td><p><code>application/x-ndjson</code></p></td><td><p><code>ndjson</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-ndjson">Newline Delimited JSON Format (ndjson)</a></p></td></tr><tr><td><p><code>application/x-www-form-urlencoded</code></p></td><td><p><code>urlencoded</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-urlencoded">URL Encoded Format</a></p></td></tr><tr><td><p><code>application/yaml</code></p></td><td><p><code>yaml</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-yaml">YAML Format</a></p></td></tr><tr><td><p><code>multipart/form-data</code></p></td><td><p><code>multipart</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-multipart">Multipart Format</a></p></td></tr><tr><td><p><code>text/plain</code></p></td><td><p><code>text</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-text">Text Plain Format</a></p></td></tr><tr><td><p><code>text/x-java-properties</code></p></td><td><p><code>properties</code></p></td><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-properties">Text Java Properties</a></p></td></tr></tbody></table>

## DataWeave Readers

DataWeave can read input data as a whole by loading it into memory or by indexing it in local
storage and, for some data formats, DataWeave can read data sequentially in parts by streaming the
input. The indexed reading strategy implements a mechanism to avoid out-of-memory issues when
processing large files. The streaming strategy can improve performance but restricts file access to
sequential access (which disallows random access) because you can access only the part of the file
that is being read and stored in memory.

<table id="streaming"><colgroup><col> <col> <col></colgroup><thead><tr><th>Read Strategy</th><th>Description</th><th>Supported Formats</th></tr></thead><tbody><tr><td><div><div><p>In-Memory</p></div></div></td><td><div><div><p>This strategy parses the entire document and loads it into memory, enabling random access to data. When using this strategy, a DataWeave script can access any part of the resulting value at any time.</p></div></div></td><td><div><div><p>DataWeave can read all supported formats using this strategy.</p></div></div></td></tr><tr><td><div><div><p>Indexed</p></div></div></td><td><div><div><p>This strategy parses the entire document and uses disk space to avoid out-of-memory issues on large files, enabling random access to data. When using this strategy, a DataWeave script can access any part of the resulting value at any time.</p></div><div><p>When processing a <code>String</code> with a size larger than 1.5 MB, DataWeave automatically splits the value in chunks to avoid out-of-memory issues. This feature works only with <code>JSON</code> and <code>XML</code> input data.</p></div><div><p>For additional details, see <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-indexed-readers">Indexed Readers in DataWeave</a></p></div></div></td><td><div><div><ul><li><p><code>CSV</code></p></li><li><p><code>JSON</code></p></li><li><p><code>XML</code></p></li></ul></div></div></td></tr><tr><td><div><div><p>Streaming</p></div></div></td><td><div><div><p>This strategy partitions the input document into smaller items and accesses the data sequentially, storing the current item in memory. A DataWeave selector can access only the portion of the file that is getting read.</p></div><div><p>For additional details, see <a href="https://docs.mulesoft.com/dataweave/2.4/dataweave-streaming">Streaming in DataWeave</a></p></div></div></td><td><div><div><ul><li><p><code>CSV</code></p></li><li><p><code>JSON</code></p></li><li><p><code>Excel</code> (XLSX)</p></li><li><p><code>XML</code></p></li></ul></div></div></td></tr></tbody></table>

## Using Reader and Writer Properties

In some cases, it is necessary to modify or specify aspects of the format through format-specific
properties. For example, you can specify CSV input and output properties, such as the `separator`
(or delimiter) to use in the CSV file. For Cobol copybook, you need to specify the path to a schema
file using the `schemaPath` property.

You can append reader properties to the MIME type (`outputMimeType`) attribute for certain
components in your Mule app. Listeners and Read operations accept these settings. For example, this
On New File listener example identifies the `,` separator for a CSV input file:

Example: Properties for the CSV Reader

```xml
<file:listener doc:name="On New File" config-ref="File_Config" outputMimeType='application/csv; separator=","'>
  <scheduling-strategy >
    <fixed-frequency frequency="45" timeUnit="SECONDS"/>
  </scheduling-strategy>
  <file:matcher filenamePattern="comma_separated.csv" />
</file:listener>
```

Note that the `outputMimeType` setting above helps the CSV _reader_ interpret the format and
delimiter of the input `comma_separated.csv` file, not the writer.

To specify the output format, you can provide the MIME type and any writer properties for the
writer, such as the CSV or JSON writer used by a File Write operation. For example, you might need
to write a pipe (`|`) delimiter in your CSV output payload, instead of some other delimiter used in
the input. To do this, you append the property and its value to the `output` directive of a
DataWeave expression. For example, this Write operation specifies the pipe as a `separator`:

Example: output Directive for the CSV Writer

```xml
<file:write doc:name="Write" config-ref="File_Config" path="my_transform">
  <file:content ><![CDATA[#[output application/csv separator="|" --- payload]]]></file:content>
</file:write>
```

The following example shows a DataWeave script in which the `output` directive specifies two writer
properties, one for the CSV field separator, another to indicate that there is no header.

```json
%dw 2.0
output application/csv separator=";", header=false
---
payload
```

Writer properties depend on the format. The following example uses the JSON writer property,
`skipNullOn`:

```json
%dw 2.0
output application/json skipNullOn="everywhere"
---
payload
```

The following example shows a DataWeave script that uses an invisible ASCII character as a separator
for the CSV output. The separator property value is `\u001E`. `\u` is the escape sequence
representation and `001E` is the hexadecimal representation of the record separator (RS) ASCII
character.

```DataWeave
%dw 2.0
output application/csv separator = "\u001E"
---
[
	{
		"Name" : "Tom",
		"UID" : 2569,
		"ShipOrderID" : "ui-288188"
	},
	{
		"Name" : "Alan",
		"UID" : 7756,
		"ShipOrderID" : "xj-232142"
	},
	{
		"Name" : "Dan",
		"UID" : 7821,
		"ShipOrderID" : "uk-259459"
	}
]
```

The CSV example produces the following output:

```csv
NameUIDShipOrderID
Tom2569ui-288188
Alan7756xj-232142
Dan7821uk-259459
```

Scripts that use the `read` or `readUrl` methods can also specify reader properties through the
`readerProperties` parameter. See examples in [read](https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-read). However, note that use
of reader properties is more common in message sources, such as the HTTP listener, as shown in the
[CSV reader example](#example_csv_reader).

It is also possible to use a Mule variable as a value of a configuration property. For more complete
examples, see
[Set Reader and Writer Configuration Properties](https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook-set-reader-writer-props).

## Setting MIME Types

You can specify the MIME type for the input and output data that flows through a Mule app.

For DataWeave transformations, you can specify the MIME type for the output data. For example, you
might set the `output` header directive of an expression in the Transform Message component or a
Write operation to `output application/json` or `output application/csv`.

This example sets the MIME type through a File Write operation to ensure that a format-specific
writer, the CSV writer, outputs the payload in CSV format:

Example: MIME Type for the CSV Writer

```xml
<file:write doc:name="Write" config-ref="File_Config" path="my_transform">
  <file:content ><![CDATA[#[output application/csv --- payload]]]></file:content>
</file:write>
```

Starting in Mule 4.3.0, you can set the `output` directive using the format ID alone, instead of
using the MIME type. For example, you might set the `output` header directive of an expression in
the Transform Message component or a Write operation to `output json` or `output csv`. You can also
use the format ID to differentiate the format of the output data from the MIME type in the output
header, and you can use a custom MIME type. For example, you can write JSON data but customize the
MIME type to `application/problem+json` by using the DataWeave directive
`output application/problem+json with json`. See
[Change a Script’s MIME Type Output](https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook-change-script-output-mime) for examples that
customize the MIME type output of a script.

The `with` keyword separates the output MIME type from the DataWeave writer for the script’s output.
For example, you can specify 'output application/csv with binary' to output the `application/csv`
MIME type when using the `binary` writer. This setting is necessary in cases shown in
[Use Dynamic Writer Properties](https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook-writer-prop-mule) and
[Use Reader and Writer Properties in DataWeave Functions](https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook-set-reader-writer-props#use-reader-and-writer-properties-in-dataweave-functions).
It is also possible to append writer properties, such as in the use case
`output application/my-custom-type with json indent=false`.

For input data, format-specific readers for Mule sources (such as the On New File listener), Mule
operations (such as Read and HTTP Request operations), and DataWeave expressions attempt to infer
the MIME type from metadata that is associated with input payloads, attributes, and variables in the
Mule event. When the MIME type cannot be inferred from the metadata (and when that metadata is not
static), Mule sources and operations allow you to specify the MIME type for the reader. For example,
you might set the MIME type for the On New File listener to `outputMimeType='application/csv'` for
CSV file _input_. This setting provides information about the file format to the CSV reader.

Example: MIME Type for the CSV Reader

```xml
<file:listener doc:name="On New File"
  config-ref="File_Config"
  outputMimeType='application/csv'>
</file:listener>
```

Note that reader settings _are not_ used to perform a transformation from one format to another.
They simply help the reader interpret the format of the input.

You can also set special reader and writer properties for use by the format-specific reader or
writer of a source, operation, or component. See
[Using Reader and Writer Properties](#reader_writer_properties).

## See Also

[Transform Message Component](https://docs.mulesoft.com/studio/transform-message-component-concept-studio)

[Flat File Schemas](https://docs.mulesoft.com/dataweave/2.4/dataweave-flat-file-schemas)
