Working with Structured Data

All data passed between nodes is technically in string (text) format. However, even though tables and data objects represented as strings, Moonlit has some internally functionalities for working with this structured data.


The most common structured data type is a table. In Moonlit, tables are represented as JSON lists of records.


{"Column A": 1, "Column B": 2},

{"Column A": 3, "Column B": 4}


if we pass this text above to a 'Table Output' node then we will get a table with two rows and two columns:

Column A Column B
1 2
3 4

Using Structured Data

Normally we reference node outputs using the double bracket notation {{node_id}}, however sometimes you will need to fetch a value nested inside the referenced object. To do that you can use 'Dot Notation' so that the reference becomes {{node_id.nested_key}}, if working with tables and we want a specific cell then we can do the following:

{{node_id.0.Column A}}

Here '0' corresponds to the first row in our table, and 'Column A' specifies the column.

This will return '1' based on the example table from the previous section.

This is important for many scenarios, many of the built-in Moonlit functions such as Google Search output a table and sometime you may want to get a single cell or row.

💡Remember that you can hover over the information icon next to the node's title to see what it outputs so that you know what the column names are when referencing it.

Forcing AI Models to output structured data

OpenAI models 'gpt-3.5 Turbo 1106' and 'gpt-4 1106' have a built-in functionality for forcing the model to respond in valid JSON format which can be activated using the 'Force JSON Response' option. You also need to specify in your prompt the structure you want your data to be in, and it's best to give the model an example.

Forcing ChatGPT to output a table

In this example above we've prompted ChatGPT to output a table with 2 columns and 10 rows, we also provided a short sample of how the data should look like. Then in our Table Output, we referenced the nested "data" object from the response to display the table.

Even for models that don't support the ability to force valid JSON, you can still use this prompting technique to achieve a structured data output, as long as the prompt is properly conveys the required result.

Need more Help?

Please reach out to us through the live chat widget on the bottom right corner or feel free to book a call with us. We're more than excited to explore and help you with your use case!