# CSV encoding repair

- Human page: https://happytails.ai/en/data-tools/csv-encoding-repair/
- Markdown: https://happytails.ai/en/data-tools/csv-encoding-repair.md
- Structured JSON: https://happytails.ai/agents/en/data-tools/csv-encoding-repair/index.json
- Visibility: public

## Tool capabilities

| Property | Value |
| --- | --- |
| Tool ID | `csv-encoding-repair` |
| Category | data-tools |
| Implementation | Registered implementation. Registration alone is not a production-quality guarantee. |
| Browser execution | Use the visible action or interactive controls. |
| Browser processing | Browser; see tool notes for network behavior. |
| HTTP API | Not callable through HTTP. |
| Browser-agent interface | run_current_tool |

### Implementation notes

Compare the previews first, then select and confirm the source encoding. The comparison does not identify the correct encoding. Export rewrites the file as quoted UTF-8 CSV; it cannot recover text already lost. Processed on your device. CSV downloads protect spreadsheet formula prefixes by default, which changes affected cells.

### Inputs and settings

No free-text input is required. Use the file inputs and/or settings below.

Accepted browser files: `.csv,.tsv,.txt,text/csv,text/plain`. Choose one file.

Browser file-input limit: 1000000 bytes in total. HTTP limits can differ.

| Setting | Meaning | Control type | Default | Constraints |
| --- | --- | --- | --- | --- |
| `delimiter` | Input CSV separator | select | "," | Allowed: ,, ;, 	 |
| `encoding` | Confirmed source encoding | select | "Compare only" | Allowed: Compare only, utf-8, windows-1252, utf-16le, utf-16be, shift_jis |
| `confirmEncoding` | I reviewed the candidate text and confirm this encoding | checkbox | false |  |
| `allowReplacement` | Allow replacement characters and possible data loss | checkbox | false |  |
| `bom` | Add UTF-8 BOM to the exported CSV | checkbox | false |  |
| `exportMode` | Spreadsheet formula handling | select | "Protect formulas" | Allowed: Protect formulas, Preserve original cells |

### Browser-agent workflow

1. Open the human page in a browser that supports WebMCP.
2. Discover the interface exposed by that page; use its actual schema.
3. Select files on the page first when the tool requires files.
4. Call `run_current_tool` with valid input and settings.
5. Inspect the returned result or error and the displayed output. Retrieve files from the displayed download links.

Calls do not automatically copy or download results. Browser permissions still apply. Interface availability alone is not proof of successful execution.

### Planning specification

One nonempty file up to 1,000,000 raw bytes, 10,000 data records, 100 columns and 100,000 data cells. Candidate previews show the first 600 decoded characters. Replacement counts include literal U+FFFD characters already in the file. Mojibake warning patterns can match legitimate text. Comparison alone produces no repaired CSV. Output is capped at 4,000,000 CSV characters.

This describes intended requirements. Use the implementation notes, interface schema and observed output to determine current support.

### Complete machine-readable capability record

```json
{
  "id": "csv-encoding-repair",
  "category": "data-tools",
  "built": true,
  "requirements": "One nonempty file up to 1,000,000 raw bytes, 10,000 data records, 100 columns and 100,000 data cells. Candidate previews show the first 600 decoded characters. Replacement counts include literal U+FFFD characters already in the file. Mojibake warning patterns can match legitimate text. Comparison alone produces no repaired CSV. Output is capped at 4,000,000 CSV characters.",
  "implementation": {
    "fields": [
      {
        "key": "delimiter",
        "label": "Input CSV separator",
        "value": ",",
        "type": "select",
        "values": [
          ",",
          ";",
          "\t"
        ]
      },
      {
        "key": "encoding",
        "label": "Confirmed source encoding",
        "value": "Compare only",
        "type": "select",
        "values": [
          "Compare only",
          "utf-8",
          "windows-1252",
          "utf-16le",
          "utf-16be",
          "shift_jis"
        ]
      },
      {
        "key": "confirmEncoding",
        "label": "I reviewed the candidate text and confirm this encoding",
        "value": false,
        "type": "checkbox"
      },
      {
        "key": "allowReplacement",
        "label": "Allow replacement characters and possible data loss",
        "value": false,
        "type": "checkbox",
        "help": "Required if the selected decoding has malformed bytes or U+FFFD characters. Replacement counts include any literal U+FFFD characters already present in the source."
      },
      {
        "key": "bom",
        "label": "Add UTF-8 BOM to the exported CSV",
        "value": false,
        "type": "checkbox"
      },
      {
        "key": "exportMode",
        "label": "Spreadsheet formula handling",
        "value": "Protect formulas",
        "type": "select",
        "values": [
          "Protect formulas",
          "Preserve original cells"
        ]
      }
    ],
    "registrationFamily": "csv-preparation",
    "presentation": "metrics",
    "note": "Compare the previews first, then select and confirm the source encoding. The comparison does not identify the correct encoding. Export rewrites the file as quoted UTF-8 CSV; it cannot recover text already lost. Processed on your device. CSV downloads protect spreadsheet formula prefixes by default, which changes affected cells.",
    "files": true,
    "multiple": false,
    "input": false,
    "accept": ".csv,.tsv,.txt,text/csv,text/plain",
    "maxFileBytes": 1000000,
    "experience": {
      "automatic": false,
      "single": false,
      "inputMaxLength": 1000000,
      "inputMode": "text",
      "label": "Raw CSV file",
      "placeholder": "Choose the original file bytes",
      "help": "Compare candidates first. Select and confirm an encoding before creating a UTF-8 CSV. Up to 1,000,000 characters. Review the settings before running.",
      "action": null
    },
    "mode": "explicit",
    "interactive": false
  },
  "execution": "Browser interface",
  "api": null,
  "browser_agent": {
    "supported": true,
    "name": "run_current_tool",
    "discovery": "WebMCP on the human page in a supporting browser",
    "verification": "See audit/API-AUDIT.md; availability is not verification"
  }
}
```

## Page guide

Compare raw CSV bytes under several character encodings and explicitly confirm a UTF-8 export after reviewing the text.

### How to use CSV encoding repair

1. Choose a raw CSV file and run Compare only.
2. Review each candidate preview, replacement count, malformed-byte flag and mojibake warnings.
3. Select the source encoding, confirm your choice and optionally add a UTF-8 BOM before exporting.

How can we improve this tool?

Report a problem or share an idea.

Please leave out private information. Your message and the tool name go to our team via PostHog.

## Useful next steps

- [CSV column calculator](https://happytails.ai/en/data-tools/csv-column-calculator/) ([Markdown](https://happytails.ai/en/data-tools/csv-column-calculator.md))

- [CSV anonymizer](https://happytails.ai/en/data-tools/csv-anonymizer/) ([Markdown](https://happytails.ai/en/data-tools/csv-anonymizer.md))

## A preview is not an encoding diagnosis

UTF-8, Windows-1252, UTF-16LE, UTF-16BE and Shift\_JIS candidates appear in a fixed order. Counts and BOM information are clues, not a confidence ranking. ASCII and many legacy files are ambiguous. No encoding is selected silently and no mojibake text is automatically rewritten.

### Understand conversion and possible loss

The output reparses CSV and writes quoted comma-separated UTF-8 with CRLF records. Parsed cell strings and quoted multiline content are retained before optional formula protection, while original quoting, delimiters and byte layout change. Malformed bytes or U+FFFD replacement characters require a separate explicit possible-loss permission. Previously lost text cannot be reconstructed.

### Local processing and exact strings

Processing runs on your device. CSV downloads quote every cell and protect spreadsheet formula prefixes by default, which changes affected strings. Preserve original cells is for trusted machine processing. Import identifiers as text in spreadsheet applications to preserve leading zeros.
