---
schema_version: "1"
id: fb531b40ec5b94d10fbaeceafc30267bbf0070a18fbefeafefe2430195f4235d
title: fromString
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dw-mime-functions-fromstring.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dw-mime-functions-fromstring
source_site: docs.mulesoft.com
content_type: documentation
content_hash: db2bbfeb97b6c3f1c9d68c30834325fe359b2b5d3bf25b2ecc5d27e2a511e451
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

# fromString

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

## fromString(mimeType: String): Result<MimeType, MimeTypeError>

Transforms a MIME type string value representation to a `MimeType`.

_Introduced in DataWeave version 2.7.0._

### Parameters

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>mimeType</code></p></td><td><p>String</p></td><td><p>The MIME type string value to transform to a <code>MimeType</code>.</p></td></tr></tbody></table>

### Example

This example transforms a MIME type string value without `parameters` to a `MimeType` value.

#### Source

```DataWeave
%dw 2.0
import * from dw::module::Mime
output application/json
---
fromString("application/json")
```

#### Output

```Json
{
  "success": true,
  "result": {
      "type": "application",
      "subtype": "json",
      "parameters": {}
  }
}
```

### Example

This example transforms a MIME type string value that includes a `parameters` to a `MimeType` value.

#### Source

```DataWeave
%dw 2.0
import * from dw::module::Mime
output application/json
---
fromString("multipart/form-data; boundary=the-boundary")
```

#### Output

```Json
{
  "success": true,
  "result": {
      "type": "multipart",
      "subtype": "form-data",
      "parameters": {
          "boundary": "the-boundary"
      }
  }
}
```

### Example

This example transforms an invalid MIME type string value.

#### Source

```DataWeave
%dw 2.0
import * from dw::module::Mime
output application/json
---
fromString("Invalid MIME type")
```

#### Output

```Json
{
  "success": false,
  "error": {
      "message": "Unable to find a sub type in `Invalid MIME type`."
  }
}
```
