1.0.1 • Published 6 months ago
@ajay7781/csv-to-json-lite v1.0.1
@ajay7781/csv-to-json-lite
🪶 Zero-dependency CSV to JSON converter – ESM, modern, Node + browser compatible
Convert CSV files or strings into structured JSON with full support for headers, quoted fields, delimiters, and custom formatting.
✨ Features
- Zero dependencies
- Works in Node.js and browser (via
fetch().text()
) - Supports headers, auto-trimming, and delimiter customization
- Modern ES module (ESM) with TypeScript-compatible output
- Optional CLI tool:
csv2json
📦 Installation
npm install @ajay7781/csv-to-json-lite
import { csvToJson } from '@ajay7781/csv-to-json-lite';
const csv = `
Name, Age, City
"Alice", 30, "New York"
"Bob", 25, "San Francisco"
`;
const data = await csvToJson(csv, {
headerCase: 'camel', // Converts 'Name' → 'name', etc.
});
console.log(data);
/*
[
{ name: 'Alice', age: '30', city: 'New York' },
{ name: 'Bob', age: '25', city: 'San Francisco' }
]
*/