---
schema_version: "1"
id: 09e170c1ac47c0c4b4c8a2cfe546be2999004df51e60b39ed9623f3900724e91
title: Event Stream Format
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dataweave-formats-eventstream.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dataweave-formats-eventstream
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a2c95efb94480069ff66b44ac8eca183b71e6a2223a522a29d566aa419580a42
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
keywords: format, eventstream, text/event-stream, text/event-stream
---

# Event Stream Format

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

MIME type: `text/event-stream`

ID: `eventstream`

DataWeave represents the Event Stream as an `Array` of `Object`, where each value is a `String`. The
output type is `Array<{_:String}>`, where each key represents a field in the event.

## Examples

These examples show uses of the event stream format.

- [Example: Simple Server Event Input](#example1)

- [Example: Ignoring Spaces After the Colon](#example2)

### Example: Simple Server Event Input

This example shows how DataWeave represents a simple server event input.

#### Input

This stream contains four blocks. The first block has one comment, and fires no events. The second
block has two fields with names `data` and `id` respectively; an event is fired with the data
`first event` and sets the last event ID to `1`. The third block fires an event with the data
`second event`; it also has an `id` field with no value, which resets the last event ID to an empty
string. The fourth block contains a `data` field with the value `third event`, which fires an event.

```event-stream
: test stream

data: first event
id: 1

data:second event
id

data:  third event
```

#### Source

The DataWeave script transforms this input into the given output.

```dataweave
%dw 2.0
output application/json
---
payload
```

#### Output

The JSON format outputs these three events.

```json
[
  {
    "data": "first event",
    "id": "1"
  },
  {
    "data": "second event",
    "id": ""
  },
  {
    "data": "third event"
  }
]
```

### Example: Ignoring Spaces After the Colon

This example shows that spaces after the colon are ignored if present.

#### Input

myInput.sse:

```event-stream
data:test

data: test
```

#### Source

This process transforms the input into JSON.

```dataweave
%dw 2.0

output application/json
---
payload
```

#### Output

The JSON output is an `Array` of the valid `Object` from the server event input.

```weave
[
  {
    "data": "test"
  },
  {
    "data": "test"
  }
]
```

## Configuration Properties

DataWeave supports these configuration properties for this format.

### Reader Properties

This format has no reader properties.

### 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></tbody></table>

## Supported MIME Types

This format supports this MIME type:

- `text/event-stream`
