Skip to main content

Langflow data types

Langflow components are designed to accept and produce specific types of inputs and outputs. Input and output data types define the structure and flow of information between components. Understanding these structures helps you build applications that provide valid input and correctly anticipate the output format.

Component ports represent the data types that each component can send and receive. Some data types are self-evident from the fields they are attached to; for example, a System Message field accepts message data. Port colors also indicate the port's data type. For example Data ports, represented by , either accept or emit structured data objects.

When building flows, connect output ports to input ports of the same type (color) to transfer that type of data between two components.

tip

In the visual editor, hover over a port to see connection details for that port.

Data

Data ports accept or produce the Data type, which is a structured data object, like a JSON payload that you might send to an API. This data type is used to pass key-value pairs between components, such as user profiles, settings, or other structured information.

Data objects include a primary text field, indicated by a text_key, and additional metadata.

Schema and attributes

The schema is defined in data.py.

The following attributes are available:

  • data: A dictionary that stores key-value pairs.
  • text_key: The key in data that is considered the primary text value.
  • default_value: Fallback if text_key is missing. The default text_key is "text".

Data structure

A Data object stores key-value pairs within the .data attribute, where each key is a field name and its value can be any supported data type. text_key tells Langflow which key in the data dictionary is the primary text value for that object.


_10
data_obj = Data(
_10
text_key="text", # Field 1
_10
data={ # Field 2 (the actual dict)
_10
"text": "Hello world",
_10
"name": "Charlie",
_10
"age": 28
_10
},
_10
default_value="" # Field 3
_10
)

Data objects can be serialized to JSON, created from JSON, or created from other dictionary data. However, the resulting Data object is a structured object with validation and methods, not a plain dictionary.

For example, when serialized into JSON, the previous example becomes the following JSON object:


_10
{
_10
"text_key": "text",
_10
"data": {
_10
"text": "User Profile",
_10
"name": "Charlie Lastname",
_10
"age": 28,
_10
"email": "charlie.lastname@example.com"
_10
},
_10
"default_value": ""
_10
}

DataFrame

DataFrame ports accept or produce pandas DataFrames, which are similar to the tabular CSV data.

Use the DataFrame type to work with data containing multiple rows or records.

Schema and attributes

The schema is defined in dataframe.py.

The following attributes are available:

  • Full pandas compatibility: All pandas DataFrame methods and functionality are supported

  • Langflow integration: Accepts lists of Data objects, dictionaries, or existing DataFrames.

  • Convenience methods:

    • to_data_list()
    • add_row()
    • add_rows()
    • to_lc_documents()
    • to_data()
    • to_message()
  • Text key support: Maintains text_key and default_value attributes for Data object compatibility.

DataFrame structure

A DataFrame has a tabular data structure with rows and columns. Keys are columns, and each object in the array is a row.


_12
[
_12
{
_12
"name": "Charlie Lastname",
_12
"age": 28,
_12
"email": "charlie.lastname@example.com"
_12
},
_12
{
_12
"name": "Alexandra Example",
_12
"age": 34,
_12
"email": "alexandra@example.com"
_12
}
_12
]

When represented as tabular data, the preceding DataFrame object is structured as follows:


_10
| name | age | email |
_10
|------|-----|-------|
_10
| Charlie Lastname | 28 | charlie.lastname@example.com |
_10
| Alexandra Example | 34 | alexandra@example.com |

Embeddings

Embeddings ports handle vector embeddings to support functions like similarity search.

For example, the Embedding Model component outputs embeddings data that you can connect to an Embedding input port on a vector store component.

LanguageModel

LanguageModel output is a specific type of output that can be produced by Language Model components. When enabled, the component's output port changes from a Message port to a Language Model port For more information, see Use the LanguageModel output.

Memory

Memory ports are available for components that store or retrieve chat memory.

Message

Message ports accept or produce Message data, which extends the Data type with additional fields and methods for text input typically used in chat flows.

The Message data type provides a consistent structure for chat interactions, and it is ideal for flows like chatbots, conversational analysis, and other LLM input and output.

Schema and attributes

The schema is defined in message.py.

The following attributes are available:

  • text: Main message content
  • sender: "User" or "AI"
  • sender_name: Display name for sender
  • session_id: Chat session identifier
  • timestamp: UTC timestamp of the message
  • files: List of file paths or images included with the message
  • content_blocks: Handles rich content input, such as text, media, or code
  • category: "message", "error", "warning", or "info".

Message structure

Message content appears in Langflow logs, GUI outputs, and the Playground as the text string alone, but this text is actually extracted from the complete structured Message object.

For example, the output string "Name: Charlie Lastname, Age: 28, Email: charlie.lastname@example.com" is extracted from the following Message object:


_10
{
_10
"text": "Name: Charlie Lastname, Age: 28, Email: charlie.lastname@example.com",
_10
"sender": "User",
_10
"sender_name": "Charlie Lastname",
_10
"session_id": "some-session-id",
_10
"timestamp": "2024-06-01T12:00:00Z",
_10
"files": [],
_10
"content_blocks": [],
_10
"category": "message"
_10
}

Text I/O components don't treat Message data as conversations

Text Input and Text Output components have Message ports, but they don't support conversational chat in the same way as Chat Input components.

When a Text Input component receives Message data, the input isn't handled in the same way that it is when passed to a Chat Input component in a chat flow. Instead, the text is treated as a static string input, not as part of an ongoing conversation.

The same is true for the Text Output component, which produces simple string output, rather than a response to a conversation.

Tool

Tool ports connect tools to an Agent component.

Tools can be other components where you enabled Tool Mode or they can be the dedicated MCP Tools component.

For more information, see Configure tools for agents and Use Langflow as an MCP client.

Unknown or multiple types

If a port can accept or produce multiple data types, it is represented by the gray port icon .

Hover over the port to see the accepted or produced data types.

View data types in flows

In Langflow, you can use Inspect output to view the output of individual components. This can help you learn about the different data type and debug problems with invalid or malformed inputs and output.

The following example shows how to inspect the output of a Type Convert component, which can convert Message, Data, or DataFrame input into Message, Data, or DataFrame output:

  1. Create a flow, and then connect a Chat Input component to a Type Convert component.

  2. In the Chat Input component, enter some text for the type converter to process.

  3. On the Type Convert component, click Run component, and then click Inspect output.

    The default output is Message data, which is the same as the input coming from the Chat Input component. To see the Message data converted to Data or DataFrame, change the Output Type on the Type Convert component, and then rerun the component.


    _10
    Input text

See also

Search