---
schema_version: "1"
id: 3558e3b73ae0683265a08dc2ef81865f1afa1ceaab25a6af8139d61b593446f7
title: URL Encoded Format
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dataweave-formats-urlencoded.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dataweave-formats-urlencoded
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 009f93b8cb29c68ec06927a828219b2d78060fcd43edf183a88c993cb7c13fac
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
keywords: format, urlencoded, application/x-www-form-urlencoded, application/x-www-form-urlencoded
---

# URL Encoded Format

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

MIME type: `application/x-www-form-urlencoded`

ID: `urlencoded`

URL encoded data represents a collection of key-value pairs. DataWeave represents these values as an
object in which each value is a string.

## Examples

The following examples show uses of the URL Encoded format:

- [Example: Represent URL Encoded Data in the DataWeave (dw) Format](#example1)

- [Example: Generate URL Encoded Data from a JSON Object](#example2)

- [Example: Generate URL Encoded Data from a Collection of Key-Value Pairs](#example3)

- [Example: Transform URL Encoded Data to the Text Plain Format](#example4)

### Example: Represent URL Encoded Data in the DataWeave (dw) Format

This example shows how DataWeave represents simple URL encoded data.

#### Input

The URL encoded data serves as input payload to the DataWeave source.

```form-urlencoded
name=Mariano&lastName=de+Achaval
```

#### Source

The DataWeave script transforms the URL encoded input payload to the DataWeave (dw) format and MIME
type.

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

#### Output

The output is a DataWeave object that contains a collection of key-value pairs from the input.

```dataweave
{
    "name": "Mariano",
    "lastName": "de Achaval"
}
```

### Example: Generate URL Encoded Data from a JSON Object

This example shows how to generate URL Encoded data.

#### Input

The JSON object serves as the input payload to the DataWeave source.

```json
{
  "name": "Mariano"
}
```

#### Source

The DataWeave script selects the value of the `name` key in the input payload and transforms all
values of the object in the body of the script to the `urlencoded` format.

```dataweave
%dw 2.0
output urlencoded
---
{
    name: payload.name,
    age: 37
}
```

#### Output

The output is URL encoded data that is constructed from the key-value pairs in the body of the
DataWeave script.

```form-urlencoded
name=Mariano&age=37
```

### Example: Generate URL Encoded Data from a Collection of Key-Value Pairs

This DataWeave script produces the URL encoded output.

#### Source

The DataWeave script transforms the format of the JSON input found within the body of the script
into the URL Encoded format.

```dataweave
%dw 2.0
output application/x-www-form-urlencoded
---
{
  "key" : "value",
  "key 1": "@here",
  "key" : "other value",
  "key 2%": null
}
```

#### Output

The output shows the input data in the URL Encoded format.

```text
key=value&key+1=%40here&key=other+value&key+2%25
```

### Example: Transform URL Encoded Data to the Text Plain Format

This example transforms URL Encoded input into the Text Plain format and MIME type.

#### Source

The DataWeave script reads the URL Encoded data and concatenates values of the selected keys.

```dataweave
%dw 2.0
var myData  read('key=value&key+1=%40here&key=other+value&key+2%25', 'application/x-www-form-urlencoded')
output text/plain
---
myData.*key[0] ++ myData.'key 1'
```

#### Output

The output is in Text Plain format.

```text
value@here
```

## Configuration Properties

DataWeave supports the following configuration properties for this format.

### Reader Properties

There are no reader properties for this format.

### 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>encoding</code></p></td><td><p><code>String</code></p></td><td><p><code>null</code></p></td><td><div><div><p>The encoding to use for the output, such as UTF-8.</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/x-www-form-urlencoded</code></p></td></tr></tbody></table>
