> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odella.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Object Block

> Create an object from input values and a JSON template

## Overview

The Object Block creates an object from input values and a JSON template. It automatically escapes input values and inserts them into the template, supporting any data type as input and outputting an object.

<Frame>
  <img src="https://mintcdn.com/odella/PGZ7enNCqh0mvwj_/block-reference/assets/object_light.png?fit=max&auto=format&n=PGZ7enNCqh0mvwj_&q=85&s=ec26012cc5bddfd397c020aa1d5f3f36" alt="Object Block Screenshot" className="block dark:hidden" width="718" height="296" data-path="block-reference/assets/object_light.png" />

  <img src="https://mintcdn.com/odella/PGZ7enNCqh0mvwj_/block-reference/assets/object_dark.png?fit=max&auto=format&n=PGZ7enNCqh0mvwj_&q=85&s=97b97975ffbd5f1c71c93edf896e2e7b" alt="Object Block Screenshot" className="hidden dark:block" width="774" height="348" data-path="block-reference/assets/object_dark.png" />
</Frame>

## Inputs

<ParamField path="(Dynamic)" type="any">
  Input values to be inserted into the JSON template. Input names are dynamically generated from the JSON template based on values wrapped in double curly braces (e.g. `{{input}}`). Non-string inputs are automatically converted to strings.
</ParamField>

## Outputs

<ResponseField name="output" type="object | object[]">
  The object or array created from the input values and JSON template. The type will be `object[]` if the template defines an array, otherwise it will be `object`.
</ResponseField>

## Editor Settings

<ParamField path="jsonTemplate" type="code" language="json" default="{ &#x22;key&#x22;: &#x22;{{input}}&#x22; }">
  The JSON template for creating the object. Input values are inserted into this template using double curly brace syntax (e.g. `{{input}}`). The template must be valid JSON.

  Values wrapped in quotes (e.g. `"{{input}}"`) will be treated as strings and escaped appropriately. Values without quotes will be inserted directly as JSON values.
</ParamField>

<ParamField path="width" type="number" default={200}>
  The width of the block in pixels.
</ParamField>

<ParamField path="hidden" type="boolean" default={true}>
  Whether the block is hidden in the block menu.
</ParamField>

## Example: Creating an object from multiple inputs

1. Add an Object Block and set the JSON Template to:
   ```json theme={"system"}
   {
     "name": "{{name}}",
     "age": {{age}},
     "job": "{{job}}"
   }
   ```
2. Add two Text Blocks with values "John Doe" and "Engineer". Connect to `name` and `job` inputs.
3. Add a Number Block with value 30. Connect to `age` input.
4. Run the flow. The Object Block output will be:
   ```json theme={"system"}
   {
     "name": "John Doe",
     "age": 30,
     "job": "Engineer"
   }
   ```

<Frame>
  <img src="https://mintcdn.com/odella/63rQpScaEp0bDpCd/images/object-block-example.png?fit=max&auto=format&n=63rQpScaEp0bDpCd&q=85&s=5d7876b2f0d9377f6c511f01e5af471d" alt="Object Block Example" width="644" height="571" data-path="images/object-block-example.png" />
</Frame>

## Error Handling

The Object Block will error if:

* The JSON Template is not a valid JSON string
* The interpolated JSON string (after inserting input values) is not valid JSON

## FAQ

<AccordionGroup>
  <Accordion title="Can I use the Object Block to create an array?">
    Yes, set the JSON Template to a valid JSON array string:

    ```json theme={"system"}
    ["{{value1}}", "{{value2}}", "{{value3}}"]
    ```
  </Accordion>

  <Accordion title="How are input values escaped?">
    Input values are automatically escaped based on whether they appear in quotes in the template:

    * Values in quotes (e.g. `"{{input}}"`) are escaped as strings using `JSON.stringify()`
    * String values in quotes get a single `JSON.stringify()`
    * Non-string values in quotes get a double `JSON.stringify()` to properly escape them
    * Values without quotes are stringified directly as JSON values
  </Accordion>

  <Accordion title="What happens to null or undefined input values?">
    If an input value is null or undefined, it will be converted to `null` in the output JSON.
  </Accordion>
</AccordionGroup>

## See Also

* [Array Block](/block-reference/data/array)
* [Text Block](/block-reference/data/text)
* [Extract Object Path Block](/block-reference/modifiers/extract-object-path)
* [Code Block](/block-reference/advanced/code)
