---
schema_version: "1"
id: 8b3bff868e03fe6322592dec00d9c5d9c64e0fd0df461669786e63adffb4815b
title: Newline Delimited JSON Format (ndjson)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dataweave-formats-ndjson.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dataweave-formats-ndjson
source_site: docs.mulesoft.com
content_type: documentation
content_hash: d0de279ce91d594b119dcbf459021fde78b852544e5edc16a6daa6d085fdf363
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# Newline Delimited JSON Format (ndjson)

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

MIME type: `application/x-ndjson`

ID: `ndjson`

DataWeave represents the Newline Delimited JSON format (ndjson) as an array of objects. Each line of
the ndjson format is mapped to one object in the array.

The following parser strategies are supported by the ndjson reader:

- In-memory

- Streaming

For details, see [DataWeave Readers](https://docs.mulesoft.com/dataweave/2.3/dataweave-formats#dw_readers_writers).

## Examples

The following examples show uses of the ndjson format.

- [Example: Transform ndjson to the DataWeave Format (dw)](#example1)

- [Example: Use the `skipInvalid`](#example2)

### Example: Transform ndjson to the DataWeave Format (dw)

This example shows how DataWeave represents simple ndjson input.

#### Input

```ndjson
{"name": "Leandro","lastName": "Shokida"}
{"name": "Mariano","lastName": "De Achaval"}
```

#### Source

The DataWeave script transforms the ndjson input to the DataWeave (dw) format and MIME type.

```ndjson
%dw 2.0
output application/dw
---
payload
```

#### Output

The DataWeave (dw) format outputs the ndjson input into an array of comma-separated objects.

```weave
[
    {"name": "Leandro","lastName": "Shokida"},
    {"name": "Mariano","lastName": "De Achaval"}
]
```

### Example: Use the `skipInvalid`

This example shows that the ndjson reader ignores all lines of ndjson data that are invalid if
`skipInvalid=true`.

#### Input

The input to the DataWeave source includes valid and invalid lines of ndjson data. Assume that the
input is from a file `myInput.ndjson`.

myInput.ndjson:

```ndjson
{"name": "Christian"
{"name": "Mariano"}
{"name": "Tomo"
{"name": "Shoki"}
```

#### Source

The DataWeave script inputs the contents of the input file `myInput.ndjson`, applies the
`skipInvalid=true` reader property, and transforms the input to the JSON format and MIME type.

```dataweave
%dw 2.0
var myInput = readUrl('classpath://myInput.ndjson', 'application/x-ndjson, {skipInvalid=true})
output application/json
---
myInput
```

#### Output

The JSON output is an array of the valid objects from the ndjson input.

```weave
[
  {
    "name": "Mariano"
  },
  {
    "name": "Shoki"
  }
]
```

## Configuration Properties

DataWeave supports the following configuration properties for the Newline Delimited JSON format
(ndjson).

### Reader Properties

The ndjson 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>ignoreEmptyLine</code></p></td><td><p><code>Boolean</code></p></td><td><p><code>true</code></p></td><td><div><div><p>Ignores any empty line. Valid values are <code>true</code> or <code>false</code>.</p></div></div></td></tr><tr><td><p><code>skipInvalid</code></p></td><td><p><code>Boolean</code></p></td><td><p><code>false</code></p></td><td><div><div><p>Skips data that is not valid ndjson. Valid values are <code>true</code> or <code>false</code>.</p></div></div></td></tr></tbody></table>

### Writer Properties

The ndjson 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 writer buffer.</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>encoding</code></p></td><td><p><code>String</code></p></td><td><p><code>'UTF-8'</code></p></td><td><div><div><p>Encoding for the ndjson reader to use.</p></div></div></td></tr><tr><td><p><code>skipNullOn</code></p></td><td><p><code>String</code></p></td><td><p><code>null</code></p></td><td><div><div><p>Valid values are <code>arrays</code> or <code>objects</code>.</p></div></div></td></tr><tr><td><p><code>writeAttributes</code></p></td><td><p><code>Boolean</code></p></td><td><p><code>false</code></p></td><td><div><div><p>Valid values are <code>true</code> or <code>false</code>.</p></div></div></td></tr></tbody></table>

## Supported MIME Types

The Newline Delimited JSON format (ndjson) supports the following MIME types.

<table><colgroup><col></colgroup><thead><tr><th>MIME Type</th></tr></thead><tbody><tr><td><p><code>application/x-ndjson</code></p></td></tr><tr><td><p><code>application/x-ldjson</code></p></td></tr></tbody></table>
