# Detect the encoding and separator of a CSV file

`POST /v1/check/file/csv/dialect`

Takes the file content as base64 and reports the encoding (UTF-8 with or without a byte order mark, UTF-16, Windows-1252 as the fallback), the separator (comma, semicolon, tab or pipe, and whether the choice is confident), the line ending, and returns the decoded text ready for the parse operation.

## Request body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| content_base64 | string | yes | The file content as base64. File content in a flow is already base64: send it as it is |

## Example request

A request body that works, as JSON.

```json
{
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}
```

## Code samples

Replace YOUR_TOKEN with your access token.

### curl

```shell
curl -X POST 'https://api.skillfulsardine.com/v1/check/file/csv/dialect' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}'
```

### PowerShell

```powershell
$body = @'
{
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}
'@
$response = Invoke-RestMethod -Method Post -Uri 'https://api.skillfulsardine.com/v1/check/file/csv/dialect' `
  -Headers @{ Authorization = 'Bearer YOUR_TOKEN' } `
  -ContentType 'application/json; charset=utf-8' `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$response | ConvertTo-Json -Depth 10
```

### Python

```python
import requests

payload = {
    "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg==",
}

response = requests.post(
    "https://api.skillfulsardine.com/v1/check/file/csv/dialect",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json=payload,
    timeout=30,
)
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.skillfulsardine.com/v1/check/file/csv/dialect", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}),
});
const result = await response.json();
console.log(result);
```

### Node

```javascript
// Node 18 or later. Save as call.mjs and run: API_TOKEN=... node call.mjs
const token = process.env.API_TOKEN;

const response = await fetch("https://api.skillfulsardine.com/v1/check/file/csv/dialect", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${token}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}),
});
const result = await response.json();
console.log(result);
```

### Rust

```rust
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }, serde_json = "1"
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let body: serde_json::Value = serde_json::from_str(r#"{
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}"#)?;
    let response = reqwest::blocking::Client::new()
        .post("https://api.skillfulsardine.com/v1/check/file/csv/dialect")
        .bearer_auth("YOUR_TOKEN")
        .json(&body)
        .send()?;
    println!("{}", response.text()?);
    Ok(())
}
```

### Swift

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.skillfulsardine.com/v1/check/file/csv/dialect")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = Data(#"""
{
  "content_base64": "bmFtZTthbW91bnQKQW5hOzEyLDUwClJ1aTs3LDAwCg=="
}
"""#.utf8)

let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))
```

## Response

The fields inside `data` of a successful response.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| encoding | string | yes | utf-8, utf-16, utf-32, windows-1252 or iso-8859-1 |
| has_byte_order_mark | boolean | yes | True when the file started with a byte order mark (removed from text) |
| separator | string | yes | The character between fields: comma, semicolon, tab or pipe |
| separator_confident | boolean | yes | False when no candidate gave the same number of columns on every row, so the separator is a guess |
| line_ending | string | yes | crlf, lf or cr, null when the file has a single line |
| text | string | yes | The decoded text, ready for the parse operation |

## Example response

A real answer from the operation, as JSON. The fields in the table above are inside `data`.

```json
{
  "data": {
    "encoding": "utf-8",
    "has_byte_order_mark": false,
    "separator": ";",
    "separator_confident": true,
    "line_ending": "lf",
    "text": "name;amount\nAna;12,50\nRui;7,00\n"
  },
  "errors": null,
  "meta": {
    "request_id": "3233e24f-ca9d-4676-bd4a-c8f7b80ec2de",
    "timestamp": "2026-10-27T07:19:42.140271Z",
    "version": "2026-03-26"
  },
  "pagination": null
}
```

## Responses

| Status | When it happens |
| --- | --- |
| 200 | Successful Response |
| 400 | The body respects the operation schema, but the use case rejected it. Each problem is one ApiError entry |
| 413 | The request is larger than the request size limit of the API allows |
| 422 | The body does not respect the operation schema. Each problem is one ApiError entry with the code validation_error |
| 500 | Something failed inside the server and was not an input problem. The same envelope, errors may be empty |

---
Source: https://skillfulsardine.com/developers/api/detect-csv-dialect/