Most online CSV/JSON/SQL converters upload your payload to someone else's server. That is a non-starter when you are cleaning customer exports, Stripe payouts, or production database dumps.

We built Data Swiss-Army Converter as a zero-dependency UMD module (converters.js, MIT) that runs 100% locally in the browser or Node.js — converting between CSV/TSV, JSON, Markdown tables, and dialect-safe SQL INSERT statements without a single network request.

Here are the three trickiest edge cases we had to solve in pure JavaScript, with the exact code running in production.

1. RFC 4180 CSV Parsing Without Mangling Long Numeric IDs

Splitting on , breaks on quoted commas, embedded newlines, UTF-8 BOMs from Excel, and semicolon-delimited European CSVs. Even worse, naive Number(val) type inference silently corrupts 18-digit Snowflake/Stripe/order IDs because IEEE 754 Number loses integer precision above 2^53 - 1 (15–16 digits).

Our parser strips the UTF-8 BOM (0xFEFF), sniffs the delimiter from the header line (,, \t, ;, |), handles doubled quotes ("") inside quoted fields, and caps automatic number inference at < 16 characters:

function inferValue(s) { if (s === '') return ''; const t = s.trim(); if (t === 'null' || t === 'NULL') return null; if (t === 'true' || t === 'TRUE') return true; if (t === 'false' || t === 'FALSE') return false; if (/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/.test(t) && t.length < 16) { return Number(t); } return s; } function detectDelimiter(text) { const first = text.split(/\r?\n/, 1)[0] || ''; const cands = [',', '\t', ';', '|']; let best = ',', bestN = 0; for (const d of cands) { const n = first.split(d).length - 1; if (n > bestN) { best = d; bestN = n; } } return best; } function parseCSV(text, opts = {}) { if (text.charCodeAt(0) === 0xfeff) text = text.slice(1); const delim = opts.delimiter || detectDelimiter(text); const infer = opts.inferTypes !== false; const rows = []; let row = [], field = '', i = 0, inQ = false, quoted = false; while (i < text.length) { const c = text[i]; if (inQ) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; continue; } inQ = false; i++; continue; } field += c; i++; continue; } if (c === '"' && field === '') { inQ = true; quoted = true; i++; continue; } if (c === delim) { row.push(field); field = ''; i++; continue; } if (c === '\r') { i++; continue; } if (c === '\n') { row.push(field); rows.push(row); row = []; field = ''; i++; continue; } field += c; i++; } if (inQ) throw new Error('CSV: unterminated quoted field'); if (field !== '' || row.length || quoted) { row.push(field); rows.push(row); } const nonEmpty = rows.filter((r) => !(r.length === 1 && r[0] === '')); if (!nonEmpty.length) return []; const headers = nonEmpty[0].map((h, idx) => h.trim() || `col${idx + 1}`); return nonEmpty.slice(1).map((r) => { const o = {}; headers.forEach((h, idx) => { const v = r[idx] === undefined ? '' : r[idx]; o[h] = infer ? inferValue(v) : v; }); return o; }); } 

When exporting back to CSV (toCSV), we also quote any cell with leading or trailing whitespace (/^\s|\s$/), preventing spreadsheets from stripping intentional padding.

2. Parsing Markdown Tables With Escaped Pipes and <br> Line Breaks

Markdown tables show up everywhere in GitHub PRs, Linear issues, and LLM outputs — and simple .split('|') falls apart as soon as a cell contains an escaped \| or multiline <br> tag.

A tiny character scanner preserves escaped pipes and converts <br> back to real \n newlines:

function splitMdRow(line) { let s = line.trim(); if (s.startsWith('|')) s = s.slice(1); if (s.endsWith('|') && !s.endsWith('\\|')) s = s.slice(0, -1); const cells = []; let cur = ''; for (let i = 0; i < s.length; i++) { const c = s[i]; if (c === '\\' && i + 1 < s.length) { cur += s[i + 1]; i++; continue; } if (c === '|') { cells.push(cur.trim()); cur = ''; continue; } cur += c; } cells.push(cur.trim()); return cells.map((c) => c.replace(/<br\s*\/?>/gi, '\n')); } 

Validating the alignment row with /^\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?$/ lets you paste an entire GitHub comment containing prose above the table and still parse cleanly.

3. Dialect-Safe SQL INSERT Generation (Postgres, MySQL, MSSQL)

Turning a JSON array or CSV export into seed SQL fails fast when column names collide with reserved keywords (order, user, group) or values contain apostrophes (O'Reilly) or nested JSON objects.

Quoting every identifier per dialect and normalizing literals makes generated SQL safe across engines:

function quoteIdent(name, dialect) { const n = String(name); if (dialect === 'mysql') return '`' + n.replace(/`/g, '``') + '`'; if (dialect === 'mssql') return '[' + n.replace(/]/g, ']]') + ']'; return '"' + n.replace(/"/g, '""') + '"'; } function sqlLiteral(v) { if (v === null || v === undefined) return 'NULL'; if (typeof v === 'number') return Number.isFinite(v) ? String(v) : 'NULL'; if (typeof v === 'boolean') return v ? 'TRUE' : 'FALSE'; if (typeof v === 'object') v = JSON.stringify(v); return "'" + String(v).replace(/'/g, "''") + "'"; } 

Try It Live (100% Offline PWA) or Grab the Pro Toolkit