Skip to main content
Data Transforms let you modify the data with JavaScript before it’s uploaded to your app. Use them to reshape, sanitize, or enrich rows in real time, from simple tasks like capitalizing text or formatting dates to complex business logic.
Where pre-validation and post-validation data transforms run in the import flow

Data Transforms

Prefer not to write code? Use the If / Else Builder to set or clear values and delete rows visually with IF / ELSE IF / ELSE conditions.

How it works

When a CSV file is uploaded, CSVbox parses the data and applies your transformation logic row by row or cell by cell. The JavaScript function you write defines how each row or field is transformed. Once the transformation is complete, the modified data passes to the next stage for validation. There are two types of Data Transforms:
  • Row Transforms: apply logic to each row individually, from top to bottom. Use them when one cell depends on other cells in the same row, for example to combine several cells into one or to run a calculation that needs input from different columns.
  • Column Transforms: apply logic to one or more selected columns at once. Use them when you need to analyze or modify the column as a whole, for example to find duplicate entries and replace each one with a unique identifier. They suit sorting, aggregation, and deduplication.
Column Transforms can slow down the importer, because the entire column dataset is loaded into memory. With large datasets, prefer Row Transforms and reserve Column Transforms for column-wide work such as deduplication or aggregation.

Row transforms

Adding row data transforms

1

Open the Data Transforms tab

On the edit sheet page, go to the Data Transforms tab and click Add Transforms.
2

Name the transform

Enter the transform Name.
3

Choose the Row type

Set Transform Type to Row.
4

Add the code

Provide the Javascript code.
5

Attach dependencies (optional)

Attach Dependent libraries.
6

Save the transform

Click Save.

Row transform examples

Append text

Append a constant to the cell value.

Normalize dates

Normalize a date value into US format.

Variables in the row transform

The csvbox object gives you access to the following data.

csvbox.row

Contains the row data. Access each cell by its column name:

csvbox.user

Contains the custom user attributes defined when initializing the importer:

csvbox.import

Contains data about the current import:

csvbox.columns

Contains the column metadata (name, type).

csvbox.environment

Contains the environment variables passed during importer initialization.
Use console.log(csvbox); to print all the available variables in the debugging console.

Column transforms

Adding column data transforms

1

Open the Data Transforms tab

On the edit sheet page, go to the Data Transforms tab and click Add Transforms.
2

Name the transform

Enter the transform Name.
3

Select the columns

Add the Columns you need for the transform.
4

Add the code

Provide the Javascript code.
5

Attach dependencies (optional)

Attach Dependent libraries.
6

Save the transform

Click Save.

Column transform examples

Example 1

Capitalize text fields:

Variables in the column transform

The csvbox object gives you access to the following data.

csvbox.column

Contains the entire column data. Access each cell by the column name and the row number. The row number starts with 1.
Only the selected columns are available in the transform JavaScript.

csvbox.user

Contains the custom user attributes defined when initializing the importer:

csvbox.import

Contains data about the current import:

csvbox.environment

Contains the environment variables passed during importer initialization.

csvbox.columns

Contains the column metadata (name, type).

console.log(csvbox);

Use this statement to print all the available variables in the debugging console.

Dependencies

The transform JavaScript can use an external library hosted on a CDN, and it can call any external API endpoint to fetch real-time data. Add the library script tag and any custom scripts to the Dependencies section, then use them in the main JavaScript snippet.

Execution time

Every Data Transform runs at one of two stages in the import pipeline, so you control when it runs:
  • Pre Data Validation (default)
  • Post Data Validation

Pre-validation data transform

Runs immediately after column mapping and before Data Validation. Use it for:
  • Cleaning or normalizing user input
  • Converting formats (dates, numbers, booleans)
  • Combining or splitting fields
  • Setting defaults
  • Preparing data that validators depend on
For example, convert a string such as " 23.4500 " into a clean numeric value before your validation rules run.

Post-validation data transform

Runs only if there are no validation errors, just before data is pushed to the final destination. Use it for:
  • Final formatting
  • Destination-specific transformations
  • Generating or enriching fields only when the row is already valid
  • Preparing computed values needed only for storage
For example, generate a slug or UUID, or apply pricing markup, after all validations pass.

Where to configure execution time

When you create or edit a Data Transform:
1

Open the Data Transforms settings

Open Sheet Settings → Data Transforms.
2

Select a transform

Select an existing transform or create a new one.
3

Choose the execution time

Set Execution Time to Pre Data Validation or Post Data Validation.
4

Save your changes

Save the transform.

Key features

  • JavaScript-powered: write custom JavaScript to operate on your data. With access to native JavaScript methods, you can implement anything from basic modifications to complex logic.
  • Real-time execution: transformations are applied as the file is uploaded, so data is processed and adjusted before it enters your app.
  • Versatile: handle a wide range of operations, such as:
    • Modifying string data (for example, capitalizing text or trimming spaces)
    • Formatting dates
    • Performing calculations, such as currency conversions
    • Validating and cleaning up data
    • Applying conditional logic to data fields
  • Error handling: include custom error handling in your JavaScript to manage issues gracefully without disrupting the upload.

Best practices

  • Handle errors: add error-handling logic to your JavaScript so malformed data doesn’t disrupt the upload.
  • Optimize performance: keep transformation code efficient, especially with large datasets, so uploads stay smooth.