CSV Cleaner API
Repair CSV files: detect the encoding (UTF-8, UTF-16, Windows-1258/1252, TCVN3, VNI), the delimiter and header, trim cells, drop empty rows and duplicates, output UTF-8.
CSV files exported from Excel and old Vietnamese software often arrive with garbled text (“Tª n”, “ViÖt Nam”, “Vieät Nam”), semicolons instead of commas, stray spaces and broken rows. The CSV cleaner detects the encoding by trying each candidate and checking which one produces real Vietnamese words: UTF-8 (with or without BOM), UTF-16 from Excel’s “Unicode text”, Windows-1258 and Windows-1252, and text typed with the legacy TCVN3 (ABC) and VNI fonts, which it converts to Unicode.
It detects the delimiter (comma, semicolon, tab, pipe) and parses quoted fields correctly, then cleans the data: trims and collapses spaces, removes invisible characters and no-break spaces, drops empty rows, pads or truncates rows to the header width, makes header names unique and optionally removes duplicate rows. The report says what was detected and changed.
The output is a UTF-8 CSV (with BOM by default, so Excel opens it with Vietnamese characters intact; comma, semicolon or tab delimiter) or JSON records.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
file | body | file | no | CSV file (multipart, raw body or file_base64), or csv text. | |
csv | body | string | no | CSV text. | |
encoding | body|query | string | no | auto | Force: utf-8, windows-1258, windows-1252, utf-16le, tcvn3, vni. |
delimiter | body|query | string | no | Input delimiter (default: detected). | |
header | body|query | boolean | no | true | The first row is a header. |
dedupe | body|query | boolean | no | false | Remove duplicate rows. |
format | body|query | string | no | csv | csv or json. |
output_delimiter | body|query | string | no | , | ,, ; or tab. |
bom | body|query | boolean | no | true | Start the CSV with a UTF-8 BOM (for Excel). |
Example
curl -X POST "https://apibox.io.vn/v1/csv-clean" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"csv":"Tên; Tuổi ;Tỉnh\n\"Nguyễn Văn An\" ; 30 ;Hà Nội\n\nTrần Thị B;25\n","format":"json"}'const res = await fetch('https://apibox.io.vn/v1/csv-clean', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"csv": "Tên; Tuổi ;Tỉnh\n\"Nguyễn Văn An\" ; 30 ;Hà Nội\n\nTrần Thị B;25\n",
"format": "json"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/csv-clean",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"csv": "Tên; Tuổi ;Tỉnh\n\"Nguyễn Văn An\" ; 30 ;Hà Nội\n\nTrần Thị B;25\n", "format": "json"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/csv-clean');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"csv":"Tên; Tuổi ;Tỉnh\\n\\"Nguyễn Văn An\\" ; 30 ;Hà Nội\\n\\nTrần Thị B;25\\n","format":"json"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"detected": {
"encoding": "utf-8",
"delimiter": ";",
"header": true
},
"rows": 2,
"columns": 3,
"report": {
"input_rows": 5,
"empty_rows_removed": 1,
"cells_trimmed": 3,
"rows_padded": 1,
"rows_truncated": 0,
"duplicates_removed": 0,
"invisible_chars_removed": 0
},
"headers": [
"Tên",
"Tuổi",
"Tỉnh"
],
"data": [
{
"Tên": "Nguyễn Văn An",
"Tuổi": "30",
"Tỉnh": "Hà Nội"
},
{
"Tên": "Trần Thị B",
"Tuổi": "25",
"Tỉnh": ""
}
]
}
Use cases
- Import customer lists from Excel without broken Vietnamese
- Convert legacy accounting exports (TCVN3 / VNI) to Unicode
- Normalise CSV uploads before loading them into a database
- Pre-clean data for spreadsheets and BI tools
FAQ
Why does Excel show broken Vietnamese in my CSV?
Excel opens CSV files as Windows-1258 / 1252 unless they start with a UTF-8 BOM. The cleaned output has a BOM by default (bom=false to remove it).
Can it fix text typed with .VnTime fonts?
Yes, TCVN3 (ABC) and VNI-Windows text is detected and converted to Unicode, even inside an otherwise UTF-8 file.
How big can the file be?
Up to the file size limit of your plan.
Related APIs
JSON Validator
Check JSON syntax with exact line and column of errors, and validate data against a JSON Schema (draft 4, 7, 2019-09 or 2020-12).
{ }JSON Formatter
Pretty print JSON with 0-8 spaces or tabs, minify it, or sort object keys recursively. Syntax errors are reported with line and column.
CSVCSV to JSON
Convert CSV into an array of JSON objects using the header row, with delimiter auto-detection, number and boolean typing, and row-level errors.