# Data Type Converter

A simple block to change the data type of an incoming value so downstream blocks receive the expected format. Use this when you need to ensure a value is treated as a number, text, list, dictionary, batch, or boolean for further processing or export.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Generic` — Any kind of data input (text, number, list, batch, etc.). Provide the value you want converted.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Generic` — The converted value in the selected target type. Use this output to feed other blocks that expect a specific data type.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Convert to` — Dropdown where you pick the target type. Available choices include `Integer`, `Boolean`, `String`, `Float`, `Batch`, `List`, and `Dictionary`.

## 🎨 Features <a href="#features" id="features"></a>

* Convert single scalar values between common types (number, text, boolean).
* Create list or batch wrappers when a collection is required by downstream blocks.
* Parse JSON-like text into a dictionary when `Dictionary` is selected and the input is a valid JSON string.
* Defensive behavior: when input is missing or incompatible, the block provides a safe default output and indicates an issue.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Connect the data source to the `Generic` input.
2. Choose the desired target type using the `Convert to` dropdown.
3. Use the block's `Generic` output as the input for downstream blocks that require the chosen type.

Common scenarios:

* Convert user-entered text to a number before applying math blocks.
* Convert a JSON string to a dictionary before exporting or parsing fields.
* Wrap a single item into a `List` or `Batch` so list-aware blocks can process it.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When the block runs, it reads the current input and outputs it in the selected format. If conversion is not possible, it outputs a safe default and logs the condition for attention.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Use `Debug Input` to inspect raw values before conversion so you can pick the correct target type.
* If you expect missing values, place `Is None` before this block to detect them and `Replace None` to insert a fallback value.
* When preparing structured payloads for logging or APIs, combine `String Merge` or `Data to JSON` with this block to produce properly formatted data.
* For batch workflows, pair this block with `Batch Concatenation`, `Get Batch Size`, or `Debatch` to inspect or flatten batch contents after conversion.
* After converting to dictionary form, persist or share results using `Data Write Local`, `Data Write Global`, or export via `CSV Export`.

(hint: use `String Input` or `Number Input` blocks as simple sources when testing conversions)

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If conversion fails or output seems unchanged, check the input value with `Debug Input` to confirm its current type and content.
* If `Dictionary` conversion doesn't work, verify the input is valid JSON text (proper quotes, commas, braces).
* When working with batches or lists, confirm the selected target (`List` vs `Batch`) matches what downstream blocks expect; use `Get Batch Size` to verify batch contents.
* For unexpected boolean conversions, ensure the input string or number follows a clear true/false convention (for example, `0`/`1` or `true`/`false`).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/data-logic/data-operations/data-type-converter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
