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 (2)
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?
Answering Abdullah's question above about what the flagged-row table actually contains:
Good question — and you're right that the reason code is what makes the handoff usable.
I keep the original order: every output row carries
source_row(the 1-based line number in the source file, header = row 1), so a flagged row can be found in the original by number instead of by eyeballing similar-looking rows. Same ordering, never re-sorted; duplicates are removed only after being written to a separateduplicate_rowslist withsource_row+reason.Per cell, both: the raw value stays exactly as typed, and the reason travels as data, not prose. Columns look like
source_row | <original columns> | duplicate | missing_fields(missing_fieldsis a comma-joined list of column names, so it is machine-filterable), plus anaudit.jsonwith input/output row counts, duplicates removed, missing-cell count and the sha256 of the source file, so the client can prove which file was cleaned.On "leave it as typed" vs "best guess shown next to it": anchoring. The moment a plausible value sits beside the raw one, the reviewer accepts it instead of deciding — and in a revenue column that is exactly how a 100x decimal-comma error survives review. So if I do compute a candidate, it goes into its own column with an explicit rule id and is never consumed downstream; the sum of the cleaned amount column is asserted equal to the sum of the raw one, so any guess that moves the money total fails the run instead of shipping.
(If you want the exact layout, the free mini sample uses the same audit.json + column structure: 2477537799006.gumroad.com/l/ebhbcm — my own toolkit, $0.)