Skip to content

Convert CSV to JSON

The CSV to JSON conversion functionality allows extracting data from CSV files and converting it into an array of JSON objects.

POST /api/v1/Csv/ConvertToJson
NameTypeRequiredDefaultDescription
FilenamestringYes-Filename of the source CSV file, must include the .csv extension
FileContentstringYes-Base64-encoded content of the CSV file
DelimiterstringNo”,“Character used to separate values in the CSV file. For tab delimiter, use \t
HeaderInFirstRowbooleanNotrueDetermines if the first row contains column headers
EncodingstringNo”UTF8”Encoding type used for text extraction. Options: “UTF8”, “Latin1”, “BigEndianUnicode”, “UTF16”, “ASCII”
MappingstringNo-JSONata mapping to transform the CSV data. For more information: https://docs.uflow.dev/jsonata
UnescapebooleanNofalseControls if quoted values are unescaped
TrimenumNo”All”Controls if values are trimmed. Options: “All”, “None”
NameTypeDescription
datastringJSON data extracted from the CSV file
schemastringJSON schema of the extracted data (either inferred or provided as input)

The conversion process works as follows:

  1. The file content is decoded from Base64 and converted to the specified encoding
  2. The CSV is parsed using a delimiter-separated values reader
  3. Each row is converted to a dictionary with column names as keys
  4. The collection of dictionaries is serialized to JSON
  5. If a JSONata mapping is provided, it’s applied to transform the data
  6. The result is returned as a string in the response
  • The filename must end with “.csv” extension
  • The file content must be a valid Base64-encoded string
  • If a mapping is provided, it will be applied to transform the output
  • The output is formatted with indentation for readability
  • The process supports different encodings for handling various text formats

Credit Cost

Cost: 1 credit(s) per 10000 rows

Note: Cost depends on the number of rows in the document

This functionality is particularly useful for data transformation workflows that need to convert CSV data into structured JSON for further processing or integration with JSON-based systems.