0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions108

Overview

This node provides a utility to convert CSV data into JSON format. It is useful when you have CSV content (e.g., exported from spreadsheets, databases, or other systems) and want to transform it into structured JSON objects for further processing in workflows. Common scenarios include importing CSV data for automation, integrating with APIs that require JSON input, or preparing data for analysis.

For example, you can input a CSV string representing user data and convert it into an array of JSON objects where each object corresponds to a row with key-value pairs based on the CSV headers.

Properties

Name Meaning
Code Variables Allows defining variables used in code editor functions by specifying variable names/IDs and their values. Useful for dynamic scripting within the node.
CSV The CSV string content to be converted. This is the raw CSV data input.
Options Collection of options to customize CSV parsing:
- Delimiter Character used to separate columns in the CSV. Default is "auto" which attempts to detect the delimiter automatically.
- Trim CSV Boolean indicating whether to trim spaces around column content (e.g., " content " becomes "content"). Defaults to true.
- CSV Headers Boolean indicating if the CSV has no header row. If true, the first row is treated as data rather than headers. Defaults to false.
- Ignore Empty Values Boolean indicating whether to skip empty values in CSV columns during conversion. Defaults to true.

Output

The output is a JSON array where each element represents a row from the CSV converted into a JSON object. Keys correspond to column headers (or generic keys if no headers are present), and values correspond to the respective cell content, optionally trimmed and filtered according to the options.

If the CSV has no header row, the output will be an array of arrays or objects with generic keys depending on implementation details.

No binary data output is produced by this operation.

Dependencies

  • Requires an API key credential for the external service powering the conversion (referred generically as "an API key credential").
  • The node makes HTTP POST requests to an endpoint related to CSV-to-JSON conversion.
  • No additional environment variables or configurations are explicitly required beyond the API key.

Troubleshooting

  • Common issues:
    • Malformed CSV input may cause errors or unexpected output. Ensure the CSV string is properly formatted.
    • Incorrect delimiter setting can lead to improper parsing; use "auto" if unsure.
    • If the CSV lacks headers but the "CSV Headers" option is not enabled, the first row might be incorrectly interpreted as headers.
  • Error messages:
    • Errors from the external API may occur if the CSV is too large or contains invalid characters.
    • Authentication errors if the API key credential is missing or invalid.
  • Resolutions:
    • Validate CSV format before input.
    • Adjust delimiter and header options appropriately.
    • Verify API key configuration in n8n credentials.

Links and References

Discussion