# TSV to CSV Converter: Delimiters, Quotes, Line Endings (`ucchiii/tsv-csv-converter`) Actor

Convert TSV to CSV, CSV to TSV, or semicolon / pipe / custom separated files from URLs or Apify datasets. Handles quoted cells, quote-all, trimming, LF/CRLF and UTF-8 / BOM / Shift_JIS / cp1252 output. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/tsv-csv-converter.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.03 / 1,000 converted rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**Convert TSV to CSV, CSV to TSV, or any separated file to semicolon, pipe or a custom character, with quoted cells kept intact**

**For anyone who gets a tab-separated export and needs a CSV, or the other way round: analysts feeding a database loader, e-commerce teams moving product lists between systems, and people in Europe whose Excel wants semicolons.** Give this Actor file URLs (or an Apify dataset that holds files), choose the output delimiter, and get **the converted file plus a public download link**. The input delimiter is detected for you.
**$0.0015 per converted file plus $0.00005 per converted row ($0.05 per 1,000 rows), header row not counted.** **The $5 monthly free credit covers about 97 files of 1,000 rows.** Failed files and the demo are free. No scraping, no API keys.

**Try it free: leave the file list empty and press Start** (clear the prefilled URL first). The demo converts a built-in sample TSV, is not charged and the result row carries `_demo: true`.

### The problems it solves

- **A TSV export has to become a CSV (or the reverse).** A find-and-replace of tabs breaks as soon as a cell contains a comma, a quote or a line break. This Actor reads the file as a table, so a cell like `"two lines"` or `5,5` stays one cell and gets quotes only where the new delimiter needs them.
- **European Excel opens a comma CSV in one column.** Convert to semicolons, CRLF line endings and UTF-8 with BOM, and it opens correctly by double-click.
- **An importer wants every cell quoted, or rejects stray spaces.** Turn on `quoteAll` and `trimCells`.
- **A legacy system wants pipes, a rare character, Shift_JIS or Windows-1252.** Pick pipe or your own single character (for example `~`), and Shift_JIS or Windows-1252 as the output encoding.

### What it does

- **Detects the input delimiter** (comma, semicolon, tab, pipe) from the first lines, or use the one you set (also any single custom character).
- **Writes the output delimiter you choose**: comma, tab, semicolon, pipe or a custom character. Quotes inside cells are doubled, cells with the delimiter, a quote or a line break are quoted.
- **Quote every cell** (optional) and **trim spaces around cells** (optional).
- **Line endings**: LF or CRLF between rows; line breaks inside quoted cells are kept.
- **Output encoding**: UTF-8 (default), UTF-8 with BOM, Shift_JIS or Windows-1252. The input encoding is detected the same way as in the CSV Encoding Converter (byte-order mark, valid UTF-8, then a statistical detector). A character the output encoding cannot hold makes that file fail for free instead of being changed.
- **Reports per file**: rows, columns, delimiters used, line endings, number of rows whose column count differs from the first row (they are kept as they are), and the file URL.
- Several files per run; each file gets its own output file and one result row.

### Input example

```json
{
  "fileUrls": ["https://example.com/exports/products.tsv"],
  "inputDelimiter": "auto",
  "outputDelimiter": "semicolon",
  "quoteAll": false,
  "trimCells": true,
  "lineEnding": "crlf",
  "outputEncoding": "utf-8-bom"
}
```

Files that an earlier step produced can come from an Apify dataset: use `datasetIds` with items like `{"fileName": "products.tsv", "contentBase64": "..."}`.

### A real example

This tab-separated file (the second cell of row 2 holds a comma, the note of row 3 holds a line break):

```
id	name	note	price
1	Sample Co.	  Tokyo, Japan 	12800
2	Test Ltd.	"two
lines"	5400
```

with `outputDelimiter: "semicolon"`, `trimCells: true`, `lineEnding: "crlf"` becomes:

```
id;name;note;price
1;Sample Co.;Tokyo, Japan;12800
2;Test Ltd.;"two
lines";5400
```

and the result row says:

```json
{
  "source": "https://example.com/exports/products.tsv",
  "status": "ok",
  "rows": 2, "columns": 4, "raggedRows": 0,
  "delimiterIn": "tab", "delimiterOut": "semicolon",
  "lineEndingIn": "lf", "lineEndingOut": "crlf",
  "targetEncoding": "utf-8-bom", "targetBom": true,
  "chargedRows": 2, "chargedFiles": 1,
  "outputKey": "products.csv",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/…/records/products.csv?signature=…"
}
```

### Output

- **Dataset**: one row per source file.
- **Key-value store**: the converted file under `outputKey`. The extension follows the output delimiter: `.csv` for comma and semicolon, `.tsv` for tab, `.txt` for pipe and custom characters. `outputUrl` is Apify's signed public link, so you can share the file without sharing your token.
- **STATS** record: files converted and failed, rows converted and rows charged.

### Limits (cannot be raised by input)

- 50 MB per source file; 50 files per run (200 MB in total for files read from datasets)
- A download is tried up to 3 times when the server is slow or answers with a temporary error (HTTP 429, 5xx); a clear error such as 404 is not retried. The timeout is 60 seconds per request
- Source URLs must be public `http` or `https` links. Addresses on internal networks (localhost, private ranges, cloud metadata) are blocked, also after redirects
- Text files only (TSV, CSV, pipe-separated and similar). Excel workbooks, PDFs and other binary files are not converted
- The custom delimiter is one character; a quote mark, a space or a line break cannot be used
- Rows are counted as records: blank lines are skipped and a quoted cell with line breaks counts once
- The first row is treated as a header and not charged; set `hasHeader` to false for files without one

### Pricing

Pay per event: **$0.0015 per converted file** (event `file`) **plus $0.00005 per converted row** (event `row`). The header row is not counted. A 1,000-row file costs $0.0515. A file that fails (download error, no data rows, characters that do not fit) is not charged. Set a maximum charge per run to cap spend; a file that does not fit in the remaining budget is skipped whole, never cut.

### FAQ

**Will a comma inside a cell break my TSV to CSV conversion?** No. The file is read as a table: that cell is written in quotes in the CSV. Quoted cells with line breaks stay one cell.
**What if the input delimiter is guessed wrong?** Set `inputDelimiter` yourself (comma, tab, semicolon, pipe or custom). The result row shows which one was used.
**Do my cells change?** Only as far as you ask: quotes follow the new delimiter, and spaces are removed only with `trimCells`. Rows with a different number of columns are kept as they are and counted in `raggedRows`.
**Does it change my source?** No. It only reads the file and writes a new one.
**Is the file link private?** Anyone holding the signed link can download that file; it gives no access to anything else in your account.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [CSV Encoding Converter](https://apify.com/ucchiii/csv-encoding-converter) — detect the encoding of CSV and text files and convert them to UTF-8 (or another encoding)
- [CSV to Excel Converter](https://apify.com/ucchiii/csv-xlsx-converter) — convert CSV, TSV, Excel XLSX, JSON and NDJSON files or Apify datasets into each other
- [CSV to JSON Converter](https://apify.com/ucchiii/csv-to-json) — turn CSV files into typed JSON: encoding and delimiter detected, numbers and booleans typed, dotted headers nested, array, NDJSON or keyed output
- [CSV Splitter](https://apify.com/ucchiii/dataset-splitter) — split a dataset or CSV/JSON file into parts by rows, parts, column value or size, or take a random sample
- [JSON to CSV Converter](https://apify.com/ucchiii/json-to-csv) — turn nested JSON files or datasets into one flat CSV file

# Actor input Schema

## `fileUrls` (type: `array`):

Public http(s) links to TSV, CSV or other delimited text files, one per entry (up to 50 files and 50 MB each). Links to internal networks are blocked. Leave this AND 'Apify datasets with files' empty to run a free demo on a built-in sample (not charged).

## `datasetIds` (type: `array`):

Optional. Dataset IDs whose items each hold one file: 'contentBase64' (the file bytes, base64-encoded) and optionally 'fileName'. Each item becomes one output file.

## `inputDelimiter` (type: `string`):

Column separator of the source files. 'auto' looks at the first lines and picks comma, semicolon, tab or pipe. Choose it yourself for other characters. Default: auto.

## `customInputDelimiter` (type: `string`):

One character; used only when the input delimiter is 'custom', for example ~ or ^.

## `outputDelimiter` (type: `string`):

Column separator of the converted file. Cells that contain it are wrapped in quotes automatically. Default: comma.

## `customOutputDelimiter` (type: `string`):

One character; used only when the output delimiter is 'custom', for example ~ or ^. A quote mark or a space is not allowed.

## `quoteAll` (type: `boolean`):

Wraps every cell in double quotes, not only the ones that need it. Some importers require this. Default: off (quotes only where needed).

## `trimCells` (type: `boolean`):

Removes leading and trailing spaces, tabs and line breaks from every cell, including the header. Default: off.

## `lineEnding` (type: `string`):

Line break between rows. Line breaks inside quoted cells are kept as they are. Default: lf.

## `outputEncoding` (type: `string`):

Encoding of the converted file. A character the encoding cannot hold makes that file fail (free) instead of being changed. The input encoding is always detected for you. Default: utf-8.

## `hasHeader` (type: `boolean`):

Rows are counted without the header row, and the price follows the row count. Turn off for files without a header (every row is counted). Default: on.

## `fileName` (type: `string`):

File name without extension; the extension follows the output delimiter (.csv, .tsv or .txt) and, with several sources, a number is added. Only letters, digits, dot, dash and underscore are kept. Empty = derived from each source name.

## Actor input object example

```json
{
  "fileUrls": [
    "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
  ],
  "inputDelimiter": "auto",
  "outputDelimiter": "comma",
  "quoteAll": false,
  "trimCells": false,
  "lineEnding": "lf",
  "outputEncoding": "utf-8",
  "hasHeader": true
}
```

# Actor output Schema

## `results` (type: `string`):

One row per source file: rows, columns, delimiters used, the output file key and its public URL (outputUrl), or the error.

## `stats` (type: `string`):

Record STATS: files converted and failed, rows converted and rows charged.

## `files` (type: `string`):

The key-value store that holds the converted output files.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "fileUrls": [
        "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/tsv-csv-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "fileUrls": ["https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/tsv-csv-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "fileUrls": [
    "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
  ]
}' |
apify call ucchiii/tsv-csv-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/tsv-csv-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/E8HgRz3r9XL40pc6I/builds/zg7szPqgNYKWy2TbY/openapi.json
