---
schema_version: "1"
id: 03c2a2a81ec29355cfd8638af4df46d827bdace69bd363b018bc4797b6aee453
title: Avro Format
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dataweave-formats-avro.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dataweave-formats-avro
source_site: docs.mulesoft.com
content_type: documentation
content_hash: be3210275a09fc90ad1c732d9af776048af0fd3eca9d3e344be36dec7327c646
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
keywords: format, avro, application/avro, application/avro
---

# Avro Format

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

MIME type: `application/avro`

ID: `avro`

Avro is a binary data format that uses a schema to structure its data. DataWeave relies on the
schema to parse the data. Avro data structures are mapped to DataWeave data structures.

## Java Value Mapping

The following table shows how Avro types map to DataWeave types.

<table><colgroup><col> <col></colgroup><thead><tr><th>Avro Type</th><th>DataWeave Type</th></tr></thead><tbody><tr><td><p><code>long</code></p></td><td><p><code>Number</code></p></td></tr><tr><td><p><code>int</code></p></td><td><p><code>Number</code></p></td></tr><tr><td><p><code>double</code></p></td><td><p><code>Number</code></p></td></tr><tr><td><p><code>boolean</code></p></td><td><p><code>Boolean</code></p></td></tr><tr><td><p><code>string</code></p></td><td><p><code>String</code></p></td></tr><tr><td><p><code>fixed</code></p></td><td><p><code>String</code></p></td></tr><tr><td><p><code>bytes</code></p></td><td><p><code>Binary</code></p></td></tr><tr><td><p><code>enum</code></p></td><td><p><code>String</code></p></td></tr><tr><td><p><code>map</code></p></td><td><p><code>Object</code></p></td></tr><tr><td><p><code>array</code></p></td><td><p><code>Array</code></p></td></tr><tr><td><p><code>null</code></p></td><td><p><code>Null</code></p></td></tr></tbody></table>

## Example: Use an Avro Schema

The following example shows how to specify a schema that the writer uses to output an Avro data
structure.

### Input

An Avro schema looks something like this.

schema.json:

```json
{
  "type": "record",
  "name": "userInfo",
  "namespace": "my.example",
  "fields": [
    {
      "name": "username",
      "type": "string",
      "default": "NONE"
    },
    {
      "name": "age",
      "type": "int",
      "default": -1
    },
    {
      "name": "phone",
      "type": "string",
      "default": "NONE"
    },
    {
      "name": "housenum",
      "type": "string",
      "default": "NONE"
    }
  ]
}
```

### Source

The `schemaUrl` property in the header of this DataWeave script passes a schema (`schema.json`) to
the DataWeave writer. The writer uses the schema to structure content from the body of the script
and output the results in Avro format.

```weave
%dw 2.0
output application/avro schemaUrl="classpath://schema.json"
---
[{
    username: "Mariano",
    age: 35,
    phone: "213",
    housenum: "123"
},
{
    username: "Leandro",
    age: 29,
    phone: "213",
    housenum: "123"
},
{
    username: "Christian",
    age: 25,
    phone: "213",
    housenum: "123"
}]
```

## Configuration Properties

DataWeave supports the following configuration properties for this format.

### Reader Properties

This format accepts properties that provide instructions for reading input data.

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><p><code>schemaUrl</code> (Required)</p></td><td><p><code>String</code></p></td><td><p><code>''</code></p></td><td><div><div><p>The URL for the Avro schema. Valid URL schemes are <code>classpath://</code>, <code>file://</code>, or <code>http://</code>. For the reader, this property is optional but defaults to the schema embedded in the input Avro file. The reader requires an embedded schema. For the writer, DataWeave requires a schema value.</p></div></div></td></tr></tbody></table>

### Writer Properties

This format accepts properties that provide instructions for writing output data.

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Type</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><p><code>bufferSize</code></p></td><td><p><code>Number</code></p></td><td><p><code>8192</code></p></td><td><div><div><p>Size of the buffer writer, in bytes. The value must be greater than <code>8</code>.</p></div></div></td></tr><tr><td><p><code>deferred</code></p></td><td><p><code>Boolean</code></p></td><td><p><code>false</code></p></td><td><div><div><p>Generates the output as a data stream when set to <code>true</code>, and defers the script’s execution until the generated content is consumed.</p></div><div><p>Valid values are <code>true</code> or <code>false</code>.</p></div></div></td></tr><tr><td><p><code>schemaUrl</code> (Required)</p></td><td><p><code>String</code></p></td><td><p><code>''</code></p></td><td><div><div><p>The URL for the Avro schema. Valid URL schemes are <code>classpath://</code>, <code>file://</code>, or <code>http://</code>. For the reader, this property is optional but defaults to the schema embedded in the input Avro file. The reader requires an embedded schema. For the writer, DataWeave requires a schema value.</p></div></div></td></tr></tbody></table>

## Supported MIME Types

This format supports the following MIME types.

<table><colgroup><col></colgroup><thead><tr><th>MIME Type</th></tr></thead><tbody><tr><td><p><code>application/avro</code></p></td></tr></tbody></table>

## Supported Top-Level Schema Types

DataWeave supports the following Avro types as the top-level element in the schema.

<table><colgroup><col></colgroup><thead><tr><th>Avro Types</th></tr></thead><tbody><tr><td><p><code>record</code></p></td></tr></tbody></table>
