---
schema_version: "1"
id: 3687cfb84e9da326c4c557f44dd42064f6689ab2c2a5962bfb132cde815b9715
title: Avro Format
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dataweave-formats-avro.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dataweave-formats-avro
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9caa3fa5f77cc07e0e5b0ded6ffc8c06bbef989f9cc9fd4c88c1f5ba2d054b8b
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# 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 Avro.

### Reader Properties (for Avro)

The Avro 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>null</code></p></td><td><div><div><p>The URL for the Avro schema. Valid values are <code>classpath://</code>, <code>file://</code>, or <code>http://</code>.</p></div></div></td></tr></tbody></table>

### Writer Properties (for Avro)

The Avro 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.</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>When set to <code>true</code>, DataWeave generates the output as a data stream, and the script’s execution is deferred until it is consumed. 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>null</code></p></td><td><div><div><p>The URL for Avro schema. Valid values are <code>classpath://</code>, <code>file://</code>, or <code>http://</code>.</p></div></div></td></tr></tbody></table>

## Supported MIME Types

The Avro 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>
