UNPKG

@ajay7781/csv-to-json-lite

Version:

Zero-dependency CSV to JSON converter (Node + Browser, modern ESM)

45 lines (30 loc) 952 B
# @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 ```bash 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' } ] */