---
title: "Cast"
description: "Cast a variable or value to a specified type."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/data-ops/cast"
---
# Cast

> Cast a variable or value to a specified type.

<block-meta block="Yes" channels="Any" folder="basic/data-ops" group="Data Operations" groupTo="/build/workflows/blocks/data-ops" icon="i-lucide-refresh-cw" pipe="Value" scope="Any" tool="No" type="data-ops.cast">



</block-meta>

**Cast** converts **Value** to **Type** and writes the result to the data pipe. Use it when a later block expects a different type than the one you already have (for example text from chat that must become a number).

If the conversion is not possible, the block fails (for example non-numeric text to **Number**, or text that is not a JSON object to **Object**).

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Value
      </strong>
    </td>
    
    <td>
      Literal or variable to convert (required)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Type
      </strong>
    </td>
    
    <td>
      <strong>
        String
      </strong>
      
      , <strong>
        Number
      </strong>
      
      , <strong>
        Boolean
      </strong>
      
      , <strong>
        Array
      </strong>
      
      , or <strong>
        Object
      </strong>
      
       (required)
    </td>
  </tr>
</tbody>
</table>

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after the value is converted
    </td>
  </tr>
</tbody>
</table>

## Pipe schema

The next block reads this on the data pipe (`pipe.value`). The type matches **Type**:

<table>
<thead>
  <tr>
    <th>
      Type
    </th>
    
    <th>
      Result
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        String
      </strong>
    </td>
    
    <td>
      Text
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Number
      </strong>
    </td>
    
    <td>
      Number. Empty text becomes <code>
        0
      </code>
      
      . Yes/no becomes <code>
        1
      </code>
      
       or <code>
        0
      </code>
      
      . Invalid text fails
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Boolean
      </strong>
    </td>
    
    <td>
      Yes/no. Text <code>
        true
      </code>
      
      , <code>
        1
      </code>
      
      , <code>
        yes
      </code>
      
      , and <code>
        on
      </code>
      
       (any case) count as yes
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Array
      </strong>
    </td>
    
    <td>
      List. Already a list is unchanged. Missing becomes <code>
        []
      </code>
      
      . JSON text that is a list is parsed; other values become a one-item list
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Object
      </strong>
    </td>
    
    <td>
      Object. Already a non-list object is unchanged. JSON text must parse to an object or the block fails
    </td>
  </tr>
</tbody>
</table>

## Use case

- Turn collected chat text into a number before [Number](https://docs.vettero.com/build/workflows/blocks/data-ops/number) or a [table](https://docs.vettero.com/build/workflows/blocks/table) write.
- Parse a JSON object string from an [API](https://docs.vettero.com/build/workflows/blocks/utility/api) response so you can bind nested keys.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
