> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/csv/converttojson.md).

# ConvertToJSON

Converts CSV string content to JSON string.

Task version: 1.5.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.CSV2/tree/main/Frends.CSV.ConvertToJSON>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                                           | Description                                                                                                                                                                                                                                                                                 |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Csv : `String`                                 | <p>Input csv string</p><p><br>Default: <code>-</code><br>Example: <code>1;Foo;Bar</code></p>                                                                                                                                                                                                |
| Delimiter : `String`                           | <p>Delimiter.</p><p><br>Default: <code>";"</code><br>Example: <code>;</code></p>                                                                                                                                                                                                            |
| ColumnSpecifications : `ColumnSpecification[]` | <p>You can map columns to specific types.</p><p>The order of the columns are used for mapping, that means that the ColumnSpecification elements need to be created in the same order as the CSV fields.</p><p><br>Default: <code>-</code><br>Example: <code>\[ { foo, String } ]</code></p> |
| {% endtab %}                                   |                                                                                                                                                                                                                                                                                             |

{% tab title="Options" %}

| Name                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |                                                                       |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| ContainsHeaderRow : `Boolean`          | <p>This flag tells the reader if there is a header row in the CSV string.</p><p><br>Default: <code>true</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                            |                                                                       |
| TrimOutput : `Boolean`                 | <p>This flag tells the reader to trim whitespace from the beginning and ending of the field value when reading.</p><p><br>Default: <code>true</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                      |                                                                       |
| SkipRowsFromTop : `Int32`              | <p>If the CSV string contains metadata before the header row you can set this value to ignore a specific amount of rows from the beginning of the csv string.</p><p><br>Default: <code>0</code><br>Example: <code>2</code></p>                                                                                                                                                                                                                                                                              |                                                                       |
| SkipEmptyRows : `Boolean`              | <p>A flag to let the reader know if a record should be skipped when reading if it's empty.</p><p>A record is considered empty if all fields are empty.</p><p><br>Default: <code>true</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                               |                                                                       |
| ReplaceHeaderWhitespaceWith : `String` | <p>If intended header value contains whitespaces replace it(them) with this string, default action is to do nothing.</p><p><br>Default:<br>Example: <code>" "</code></p>                                                                                                                                                                                                                                                                                                                                    |                                                                       |
| CultureInfo : `String`                 | <p>The culture info to read/write the entries with, e.g. for decimal separators.</p><p>InvariantCulture will be used by default.</p><p>See list of cultures here: <https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.name?view=net-7.0></p><p>NOTE: Due to an issue with the CsvHelpers library, all CSV tasks will use the culture info setting of the first CSV task in the process; you cannot use different cultures for reading and parsing CSV files in the same process. | </p><p><br>Default: <code>-</code><br>Example: <code>fi-FI</code></p> |
| TreatMissingFieldsAsNulls : `Boolean`  | <p>The flag for reader to treat missing fields as nulls instead of throwing a MissingFieldException.</p><p>In case of providing column specifications manually the value of empty field defined as string will be empty instead of null</p><p><br>Default: <code>true</code><br>Example: <code>true</code></p>                                                                                                                                                                                              |                                                                       |
| IgnoreQuotes : `Boolean`               | <p>A flag to let the reader know if quotes should be ignored.</p><p><br>Default: <code>false</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                      |                                                                       |
| ThrowErrorOnFailure : `Boolean`        | <p>Whether to throw an error on failure.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                             |                                                                       |
| ErrorMessageOnFailure : `String`       | <p>Overrides the error message on failure.</p><p><br>Default: <code>-</code><br>Example: <code>Order validation failed: missing customer ID</code></p>                                                                                                                                                                                                                                                                                                                                                      |                                                                       |
| {% endtab %}                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                                                       |
| {% endtabs %}                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                                                       |

## Task Result

| Name                               | Description                                                                                                    |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`                | <p>Indicates whether the operation completed successfully.<br>Example: <code>true</code></p>                   |
| Json : `Object`                    | <p>Result as JToken.<br>Example: <code>{\[ {"value": "1", "foos": "foo", "bars": "bar"} ]}</code></p>          |
| Error : `Error`                    | <p>Error details. Null when Success is true.<br>Example: <code>null</code></p>                                 |
| Error.Message : `String`           | <p>Error message.<br>Example: <code>CSV input can not be empty</code></p>                                      |
| Error.AdditionalInfo : `Exception` | <p>Additional information about the error, typically the original exception.<br>Example: <code>null</code></p> |

## Task Changelog

Changelog for Task Frends.CSV.ConvertToJSON.

### \[1.5.0] - 2026-10-08

#### Fixed

* Fix inverted logic of trimming option.

### \[1.4.0] - 2026-08-20

#### Changed

* Upgraded target framework from .NET 6 to .NET 8.
* Added error handling support with ThrowErrorOnFailure and ErrorMessageOnFailure options.
* Added Error property to the Result object for accessing error details when ThrowErrorOnFailure is false.

### \[1.3.0] - 2026-05-22

#### Changed

* Update package Newtonsoft.Json to version 13.0.4.
* Improved memory usage and performance when converting large CSV files by implementing streaming JSON output.

### \[1.2.0] - 2025-05-12

#### Changed

* Update package CsvHelper to version 33.1.0.

### \[1.1.0] - 2025-11-18

#### Added

* Added IgnoreQuotes parameter to Options class. When set to true, quotes are treated as regular characters, allowing proper handling of CSV data with special characters in property names.

### \[1.0.0] - 2023-08-25

#### Changed

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/csv/converttojson.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
