# CSV Encoding Converter: Shift-JIS to UTF-8 & more (`ucchiii/csv-encoding-converter`) Actor

Fix garbled CSV and text files: detects the encoding (Shift_JIS, GBK, Big5, Windows-1252, UTF-8 and more) and re-saves as UTF-8 with or without BOM for Excel, or another encoding. Unifies delimiter and line endings. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/csv-encoding-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/running/actors-in-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

**Fix CSV files that show garbled text: detect the encoding and re-save as UTF-8**

**For anyone who opens a CSV and sees `ƒTƒ“ƒvƒ‹`, `Ã©`, `?????` or boxes instead of names: Japanese, Chinese, Korean, Cyrillic and Western European files saved in an old encoding (Shift_JIS, EUC-JP, GBK, Big5, Windows-1252 and others).** Give this Actor file URLs, choose the output encoding, and get **the converted file plus a public download link**. The source encoding is detected for you (byte-order mark, valid UTF-8, then a statistical detector) and the result row tells you what it found and how sure it is.
**$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,000 rows in 1,000-row files.** 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 Shift_JIS sample, is not charged and the result row carries `_demo: true`.

### The problems it solves

- **A CSV from a Japanese, Chinese or Korean system looks like random symbols in your tool.** Accounting, e-commerce, logistics and government exports are often still Shift_JIS, GBK, Big5 or EUC-KR. Convert to UTF-8 and every character comes out right.
- **Excel shows broken characters in a UTF-8 CSV.** Turn on the UTF-8 BOM (or save as UTF-16) and Excel opens it correctly by double-click.
- **A legacy system only accepts Shift_JIS or Windows-1252.** Convert the other way. Characters the target cannot hold are never lost silently: the file fails and names them, or you choose to replace or drop them and get the count.
- **Files from different sources use different separators and line breaks.** Unify them to comma, semicolon, tab or pipe, and to LF, CRLF or CR, in the same pass.

### What it does

- **Detects the input encoding**: UTF-8 (with or without BOM), UTF-16/32 with BOM, Shift_JIS (Windows-31J), EUC-JP, ISO-2022-JP, GBK / GB2312 / GB18030, Big5, EUC-KR / CP949, Windows-1250 / 1251 / 1252 / 1253 / 1254 / 1256, ISO-8859 and KOI8-R. Or choose the encoding yourself when you know it.
- **Converts to UTF-8** (with or without BOM) **or to any encoding in the list**, including UTF-16 for Excel's "Unicode text".
- **Detects the delimiter** (comma, semicolon, tab, pipe) and changes it on request; quotes are added only where needed, and line breaks inside quoted cells are kept.
- **Unifies line endings** (mixed endings in one file become one style).
- **Leaves the text alone otherwise**: with the delimiter on "keep" the content is re-encoded as it is, so odd quoting or extra lines are not touched.
- **Reports** the detected encoding and method, a 0 to 1 confidence, row and column counts, delimiters, line endings and the number of changed characters.
- Several files per run; each file gets its own output file and one result row.

### Input example

```json
{
  "fileUrls": ["https://example.com/exports/orders.csv"],
  "targetEncoding": "utf-8",
  "utf8Bom": true,
  "outputDelimiter": ",",
  "lineEnding": "crlf"
}
```

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

### Output

- **Dataset**: one row per source file.
- **Key-value store**: the converted file under `outputKey` (for example `orders-utf8.csv`). `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.

```json
{
  "source": "https://example.com/exports/orders.csv",
  "status": "ok",
  "detectedEncoding": "shift_jis", "detectionMethod": "statistical", "confidence": 1,
  "targetEncoding": "utf-8", "targetBom": true,
  "rows": 2500, "columns": 5,
  "delimiterIn": "comma", "delimiterOut": "comma", "lineEndingIn": "crlf", "lineEndingOut": "crlf",
  "replacedChars": 0, "inputBytes": 118204, "outputBytes": 131905, "chargedRows": 2500, "chargedFiles": 1,
  "outputKey": "orders-utf8.csv",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/…/records/orders-utf8.csv?signature=…"
}
```

### 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 (CSV, TSV and similar). Excel workbooks, PDFs and other binary files are not converted
- Rows are counted as records: blank lines are skipped and a quoted cell with line breaks counts once

### 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. If none of the files fit, nothing is converted or charged and the run ends as Failed ("No file could be converted. See the dataset rows for the reason."); each skipped file's row in the dataset says "Max charge reached before this file; it was not converted."
On the Apify Free plan, the $5 of monthly platform credit covers about **100,000 rows** a month, enough to try it on real data.

### FAQ

**How does it know the encoding?** First a byte-order mark, then whether the bytes are valid UTF-8, then a statistical detector. Detection is a best guess: very short files can be ambiguous, and the confidence is a rough guide, not a guarantee (when several single-byte encodings fit, it prefers the Windows ones: Windows-1252, 1251, 1253). If the output looks garbled, set `sourceEncoding` yourself (for example `cp1250` for Central European text or `koi8_r` for old Russian files). The result row shows `detectionMethod` and `confidence`; set the input encoding yourself if the guess is wrong.
**Shift_JIS or Windows-31J?** Files are read and written as Windows-31J (CP932), the variant that Windows tools produce. It includes characters such as ① and ㈱.
**Excel still shows broken characters.** Choose `utf-8` with the BOM turned on, or `utf-16`.
**What happens to characters the output encoding cannot hold?** By default the file fails, nothing is charged and the error lists the characters. With "replace" they become `?`, with "drop" they are removed; `replacedChars` says how many.
**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 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
- [Japanese Text Toolkit](https://apify.com/ucchiii/japanese-text-toolkit) — furigana, romaji, wareki dates and normalization for Japanese text
- [JSON to CSV Converter](https://apify.com/ucchiii/json-to-csv) — turn nested JSON files or datasets into one flat CSV file
- [Excel to JSON](https://apify.com/ucchiii/excel-to-json) — turn Excel (XLSX) sheets into JSON rows, or a JSON file into an Excel sheet
- [Dataset Transform](https://apify.com/ucchiii/dataset-transform) — flatten, filter, rename and convert any Apify dataset, export CSV / JSON / JSONL with a link

# Actor input Schema

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

Public http(s) links to CSV, TSV or other 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'. Use this when an earlier step produced the file content. Each item becomes one output file.

## `sourceEncoding` (type: `string`):

Encoding of the source files. 'auto' checks the byte-order mark, then whether the file is valid UTF-8, then a statistical detector; the result row shows what was found and how sure it is. Choose one yourself if the guess is wrong. Default: auto.

## `targetEncoding` (type: `string`):

Encoding of the converted file. Default: utf-8. Characters that the output encoding cannot hold are handled by 'Characters that do not fit'.

## `utf8Bom` (type: `boolean`):

Adds a byte-order mark to UTF-8 output so Excel opens non-English text (Japanese, Chinese, accents) correctly by double-click. Leave off for pandas, databases and most code. Only used when the output encoding is utf-8. Default: off.

## `unmappable` (type: `string`):

What to do when the output encoding cannot hold a character, for example an emoji in a Shift_JIS file. 'fail' keeps your data exact and the error names the characters. The number of changed characters is reported as replacedChars. Default: fail.

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

Column separator of the source files, used for counting rows and for changing the separator. 'auto' looks at the first lines. Default: auto.

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

Column separator of the converted file. 'keep' leaves the text as it is; any other value reads the file as CSV and rewrites it (quotes are added only where needed). Default: keep.

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

Line break style of the converted file; mixed line endings in the source become one style. Default: keep (the most common style in the file).

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

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

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

File name without extension for the output; the encoding is appended (name-utf8.csv) and, with several sources, a number. 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"
  ],
  "sourceEncoding": "auto",
  "targetEncoding": "utf-8",
  "utf8Bom": false,
  "unmappable": "fail",
  "inputDelimiter": "auto",
  "outputDelimiter": "keep",
  "lineEnding": "keep",
  "hasHeader": true
}
```

# Actor output Schema

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

One row per source file: detected encoding, rows, output encoding, the output file key and its public URL (outputUrl), or the error. Download as CSV, JSON, Excel and more.

## `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/csv-encoding-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/csv-encoding-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/csv-encoding-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/csv-encoding-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/NDPK0JFU0bekEEE4P/builds/2oMDCH5Y6U2fIEFXo/openapi.json
