Skip to main content
Version: 1.11.x

Data Operations

tip

Prior to Langflow 1.11.0, text, JSON, and table processing were handled by separate Text Operations, JSON Operations, and Table Operations components.

The Data Operations component performs operations on Message, JSON, or Table inputs. Set Input Type to choose which operation set is available. The output type depends on the selected operation and input type.

Use the Data Operations component in a flow

This example demonstrates a complete data transformation pipeline using multiple Data Operations components with different input types.

Send a sample JSON message to the webhook, and the pipeline extracts the products array, filters products with stock greater than zero, sorts them by price, and displays the filtered results.

A data transformation flow using Data Operations component with Webhook, Type Convert, and Chat Output components

  1. Add a Webhook component to receive JSON data.

  2. Add a Data Operations component to select keys. Set Input Type to JSON, Operation to Select Keys, and enter the key products to extract the products array.

  3. Add a Type Convert component to convert JSON to Table. Set Input Type to JSON and Output Type to Table.

  4. Add another Data Operations component to filter rows. Set Input Type to Table, Operation to Filter, Column Name to stock, Filter Operator to greater than, and Filter Value to 0.

  5. Add another Data Operations component to sort the results. Set Input Type to Table, Operation to Sort, Column Name to price, and enable Sort Ascending.

  6. Add a Chat Output component to display the results.

  7. To test your flow, send the following JSON to your webhook endpoint. Replace YOUR_FLOW_ID with the UUID of your flow.

    curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \
    -H "Content-Type: application/json" \
    -d '{
    "store": "Electronics Warehouse",
    "location": "New York",
    "products": [
    {
    "name": "Widget A",
    "price": 29.99,
    "stock": 10,
    "category": "Electronics"
    },
    {
    "name": "Widget B",
    "price": 49.99,
    "stock": 5,
    "category": "Electronics"
    },
    {
    "name": "Widget C",
    "price": 19.99,
    "stock": 0,
    "category": "Electronics"
    },
    {
    "name": "Widget D",
    "price": 39.99,
    "stock": 15,
    "category": "Electronics"
    },
    {
    "name": "Widget E",
    "price": 59.99,
    "stock": 3,
    "category": "Electronics"
    }
    ]
    }'

The result should be a Table of in-stock products sorted by price in the Playground. To inspect each Data Operations component's transformation step in the pipeline, click Inspect output.

Examples

Clean text from a language model

The following example demonstrates how to use a Data Operations component to clean text output from a language model before passing it to another component:

  1. Create a flow with a Language Model component and a Data Operations component, and then connect the Language Model component's Message output to the Data Operations component's Text Input.

    All text operations require a text string as input. If the preceding component doesn't produce Message or text output, you can use the Type Convert component to reformat the data first.

  2. Set Input Type to Text, and then select Text Clean in the Operation field.

    tip

    You can select only one operation. If you need to perform multiple operations, chain multiple Data Operations components together to execute each operation in sequence.

  3. Enable Remove Extra Spaces and Remove Empty Lines to normalize the model's output.

  4. Optional: Connect the output to a Chat Output component to view the result in the Playground.

  5. Click Run component on the Data Operations component, and then click Inspect output to view the result.

Data Operations parameters

Many parameters are conditional based on the selected Input Type and Operation.

Some parameters are hidden by default in the visual editor. You can modify all component parameters through the component inspection panel that appears when you select a component.

Available when Input Type is set to Text. Most text operations return a Message. Word Count returns a JSON object, and Text to DataFrame returns a Table.

NameDisplay NameInfo
text_inputText InputInput parameter. The text string to process. Required for all operations.
operationOperationInput parameter. The operation to perform on the text. See Available text operations.
case_typeCase TypeInput parameter. The case conversion to apply. Options: uppercase, lowercase, title, capitalize, swapcase. Default: lowercase. Only shown for Case Conversion.
search_patternSearch PatternInput parameter. The text or regex pattern to find. Only shown for Text Replace.
replacement_textReplacement TextInput parameter. The text to substitute for each match. Only shown for Text Replace.
use_regexUse RegexInput parameter. If enabled, treats Search Pattern as a regular expression. Default: Disabled. Only shown for Text Replace.
extract_patternExtract PatternInput parameter. The regular expression pattern to match against the text. Only shown for Text Extract.
max_matchesMax MatchesInput parameter. Maximum number of matches to return. Default: 10. Only shown for Text Extract.
head_charactersCharacters from StartInput parameter. Number of characters to return from the beginning of the text. Must be non-negative. Default: 100. Only shown for Text Head.
tail_charactersCharacters from EndInput parameter. Number of characters to return from the end of the text. Must be non-negative. Default: 100. Only shown for Text Tail.
strip_modeStrip ModeInput parameter. Which side(s) of the text to strip. Options: both (default), left, right. Only shown for Text Strip.
strip_charactersCharacters to StripInput parameter. Specific characters to remove. Leave empty to strip whitespace. Only shown for Text Strip.
text_input_2Second Text InputInput parameter. The second text string to join with the first. Only shown for Text Join.
remove_extra_spacesRemove Extra SpacesInput parameter. Collapse multiple consecutive spaces into a single space. Default: Enabled. Only shown for Text Clean.
remove_special_charsRemove Special CharactersInput parameter. Remove all characters except alphanumeric and spaces. Default: Disabled. Only shown for Text Clean.
remove_empty_linesRemove Empty LinesInput parameter. Remove blank lines from the text. Default: Disabled. Only shown for Text Clean.
table_separatorTable SeparatorInput parameter. The character used to delimit columns. Default: |. Only shown for Text to DataFrame.
has_headerHas HeaderInput parameter. Whether the first row is a header row. Default: Enabled. Only shown for Text to DataFrame.
count_wordsCount WordsInput parameter. Include word count and unique word count in the output. Default: Enabled. Only shown for Word Count.
count_charactersCount CharactersInput parameter. Include character count (with and without spaces) in the output. Default: Enabled. Only shown for Word Count.
count_linesCount LinesInput parameter. Include total and non-empty line count in the output. Default: Enabled. Only shown for Word Count.

Available text operations

NameRequired InputsOutputProcess
Word CountNoneJSONCounts words, unique words, characters, and lines in the text.
Case Conversioncase_​typeMessageConverts the text to the specified case.
Text Replacesearch_​pattern, replacement_​text, use_​regexMessageReplaces occurrences of a pattern with replacement text.
Text Extractextract_​pattern, max_​matchesMessageExtracts all substrings matching a regex pattern, returned as newline-separated text.
Text Headhead_​charactersMessageReturns the first n characters of the text.
Text Tailtail_​charactersMessageReturns the last n characters of the text.
Text Stripstrip_​mode, strip_​charactersMessageRemoves whitespace or specified characters from the edges of the text.
Text Jointext_​input_​2Text, MessageConcatenates two text inputs separated by a newline.
Text Cleanremove_​extra_​spaces, remove_​special_​chars, remove_​empty_​linesMessageNormalizes text by removing extra spaces, special characters, and empty lines.
Text to DataFrametable_​separator, has_​headerTableConverts a delimiter-separated text table into a Table.

See also

Was this page helpful?

Support
Search