Skip to main content

Data Conversion

Transform data between formats to connect components that speak different languages.

What is Data Conversion?

The Data Conversion node bridges the gap between components that require different data formats. It functions as a translator, transforming input from one format (Text, Number, JSON, File, or Boolean) into another, enabling seamless connections throughout your workflow.

Think of it as a universal adapter that ensures data flows smoothly between components with different requirements, eliminating format mismatch errors.

How to use it?

  1. Add to Workflow:

    • Drag the Data Conversion node onto your canvas
    • Position it between components that need format conversion
  2. Configure Input Type:

    • Connect the source node's output to the Data Conversion input
    • In the Data Conversion settings, select the appropriate input type from: Text, Number, JSON, File, or Boolean
    • The input type should match what's coming from your source node
  3. Set Output Format:

    • Select your desired output format from the same options
    • Connect the Data Conversion output to your target node's input
    • The output type should match what your target node expects
  4. Test Conversion:

    • Run your workflow to verify the conversion works as expected
    • Check for appropriate error messages if conversion fails

Example of usage

Using the Data Conversion node in combination with other nodes to achieve a seamless data transformation.

Example of usage

Let's walk through a practical example that showcases the power of the Data Conversion node in a real workflow.

Website Scraping with JSON Processing

In this workflow, we'll get data from an API, convert the text to JSON, extract specific information, and display the results:

  1. Set API Action:

  2. Convert Text to JSON:

    • Add a Data Conversion node after the API Action
    • Connect API Actions's text output to Data Conversion's input
    • Set input type to "Text" and output type to "JSON"
  3. Extract Data with JSON Query:

    • Add a JSON Query node after Data Conversion
    • Connect Data Conversion's JSON output to JSON Query's input
    • Configure a query to extract specific information
    • Set JSON Query's output to Text format
  4. Display Results:

    • Connect JSON Query output to an Output node

This workflow demonstrates how Data Conversion enables you to transform scraped web content into structured JSON that can be queried and processed programmatically.

Conversion Capabilities

Data Conversion supports many transformations between data types. Here's what happens in key scenarios:

Text Conversions

  • Text → JSON: Parses valid JSON-formatted strings into JSON objects
  • Text → File: Creates a file containing the text content
  • Text → Number: Converts numeric strings to actual numbers
  • Text → Boolean: Converts boolean strings to actual boolean

JSON Conversions

  • JSON → Text: Serializes JSON objects to formatted strings
  • JSON → File: Saves JSON as a text file
  • JSON → Number: Works only if the JSON value is a single numeric value
  • JSON → Boolean: Works only if the JSON value is a single boolean value

File Conversions

  • File → Text: Extracts textual content from the file
  • File → JSON: Attempts to parse file content as JSON (must contain valid JSON)
  • File → Number: Extracts textual content from the file and outputs it as number, works only if that content is a number
  • File → Boolean: Extracts textual content from the file and outputs it as boolean, works only if that content is a boolean value

Number Conversions

  • Number → Text: Converts the numeric value to its string representation
  • Number → JSON: Creates a JSON number primitive
  • Number → Boolean: Converts a number to a boolean, all values other than 0 are true
  • Number → File: Wraps a number in a file

Boolean Conversions

  • Boolean → Text: Creates "true" or "false" strings
  • Boolean → Number: True is converted to 1, false will throw an error

Best Practices

  • Type Checking: Always ensure your input data matches the selected input type
  • Error Handling: Some conversions may fail if input data isn't compatible (e.g., converting "hello" to a Number)
  • Complex Transformations: For more advanced conversions, consider using multiple Data Conversion nodes or combining with Template or Code nodes
  • Debugging: If your workflow fails, check if the Data Conversion node is receiving the expected format

By strategically placing Data Conversion nodes in your workflow, you can eliminate format compatibility issues and create more robust, versatile applications.