Last night I built a free CSV cleaner
that runs entirely in the browser. Not because the world needs another CSV tool, but because
I sell a "send me your messy sheet, I'll clean it" service and the funnel was empty. A free
tool that actually works is the cheapest way to prove competence.
While writing it I hit two bugs that would have silently corrupted money. Both were caught by
tests, and both are worth stealing.
Bug 1: the decimal comma that multiplied amounts by 100
European files write 1200,00. US files write 1,200.00. My first parser stripped commas as
thousands separators, so 1200,00 became 120000 — a 100× error, silently, on every row.
The fix is not "be smarter about locales". It is a small decision tree where ambiguity loses:
if (/^\d{1,3}(\.\d{3})+(,\d+)?$/.test(s)) {
s = s.replace(/\./g, "").replace(",", "."); // 1.234,50 -> 1234.50
} else if (s.includes(",") && !s.includes(".")) {
if (/^\d+,\d{2}$/.test(s)) s = s.replace(",", "."); // 1200,00 -> 1200.00
else if (/^\d{1,3}(,\d{3})+$/.test(s)) s = s.replace(/,/g, ""); // 1,200 -> 1200
else return null; // ambiguous: flag it, never guess
} else if (s.includes(",") && s.includes(".")) {
if (/^\d{1,3}(,\d{3})+(\.\d+)?$/.test(s)) s = s.replace(/,/g, "");
else return null;
}
return null means the cell is left exactly as typed and listed in a "needs a human eye" table.
On financial data, a wrong guess is worse than an unprocessed cell, because nobody notices it.
Bug 2: "fixed" dates that were still wrong
13/13/2026 should fail. Mine produced 2026-13-13 — a date that looks normalised, sorts
wrong, and breaks every downstream query. The validator needed to check the month, not only
whether the pattern matched:
const dmy = s.match(/^(\d{1,2})[.\/-](\d{1,2})[.\/-](\d{4})$/);
if (dmy && Number(dmy[1]) > 12 && Number(dmy[2]) <= 12) {
return `${dmy[3]}-${dmy[2].padStart(2, "0")}-${dmy[1].padStart(2, "0")}`;
}
The tests that earned their keep
24 assertions, no framework — node test_cleaner.js, exit code 0 or it's broken. The three that
mattered most:
-
parseAmount("1200,00") === 1200(not 120000) -
parseDate("13/13/2026") === null(never a fake date) - cleaning must not change the sum of the amount column — that single assertion caught both bugs
ok("sum of amounts unchanged by cleaning", () => {
const sum = result.rows.filter((r) => /^-?\d+(\.\d+)?$/.test(r[2]))
.reduce((a, r) => a + Number(r[2]), 0);
assert.equal(Math.round(sum * 100) / 100, 1344.5);
});
If your cleaner can't state an invariant like that, you don't know what it did to the file.
What the tool does, and what it refuses to do
It trims cells, drops fully empty rows, drops exact duplicates (first occurrence wins),
normalises dates to YYYY-MM-DD when the meaning is unambiguous, and converts $1,234.50,
1.234,50 and (45.00) to plain decimals. Anything else is flagged.
It does not upload your file. There is no server: open the network tab and watch nothing
happen. That is also why it's free to run — the work is your browser's.
Try it: free CSV cleaner ·
proof run on a real 514-row sheet: csv-cleanup-proof
If a sheet is too far gone for a tool — merged header rows, amounts split across columns,
three date conventions in one file — that's what the done-for-you cleanup
is for: $49, one file, back within 24 hours with a page listing every change and every row I
refused to guess on.
Top comments (1)
This is the kind of bug story I actually learn from — the 100x decimal-comma error is terrifying precisely because it passes every smell test: the file still parses, the numbers still look plausible, and nothing raises. Your "ambiguity loses" rule is the right call, and the invariant test is the real gem here. Most test suites assert on single rows; asserting that cleaning must not change the sum of the amount column catches the whole class of bug, not just the instance.
I also liked that 13/13/2026 produced a fake normalized date instead of failing — pattern-matching without range-checking is a trap I have seen in date parsing on Android too, where locale-dependent formats sneak in from user input.
One thing I am curious about: when a cell lands in the "needs a human eye" table, do you keep the original row order and a reason code per cell, or just the cell value? In my experience the reason code is what makes the handoff usable — otherwise the human has to re-derive why it was flagged. What made you pick "leave it exactly as typed" over flagging it with a best-guess value shown alongside the original?