npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@uchina-systems/csv-to-json

v0.1.9

Published

CSV to JSON converter with WASM (Edge/Browser) and Node native add-on

Readme

@uchina-systems/csv-to-json

CSV → JSON converter with a hybrid runtime: WASM for Edge/Browser, and a native N-API add-on for Node. One npm package that “just works” everywhere with the same API.

Install

npm install @uchina-systems/csv-to-json

What you get

  • Edge/Browser: WebAssembly build for fast client/edge parsing and validation
  • Node: Native add-on for server-side throughput
  • Unified API with options, including header handling, delimiter, and optional case normalization

JavaScript/TypeScript usage

The package auto-selects the correct runtime via conditional exports. You can import the same way in Node, Edge, and the browser.

Node (native)

import { parse, parseToArray } from '@uchina-systems/csv-to-json'
import fs from 'node:fs'

const csv = fs.readFileSync('data.csv')
const json = parse(csv, { headers: true, caseStyle: 'pascal' })
console.log(json)

const rows = parseToArray(csv, { headers: true, caseStyle: 'pascal' })
console.log(rows)

Edge/Browser (WASM)

import { parse, parseToArray } from '@uchina-systems/csv-to-json'

const bytes = new TextEncoder().encode('YouTube link,IMPORT\nhttps://yt.com,YES\n')
const json = parse(bytes, { headers: true, caseStyle: 'pascal' })
// => [{"YouTubeLink":"https://yt.com","Import":"YES"}]

const rows = parseToArray(bytes, { headers: true, caseStyle: 'pascal' })
// => [{ YouTubeLink: 'https://yt.com', Import: 'YES' }]

Next.js examples

Edge route (app/api/parse/route.ts)

export const runtime = 'edge'
import { NextResponse } from 'next/server'
import { parse } from '@uchina-systems/csv-to-json'

export async function POST(req: Request) {
  const bytes = new Uint8Array(await req.arrayBuffer())
  const json = parse(bytes, { headers: true, caseStyle: 'pascal' })
  return NextResponse.json(JSON.parse(json))
}

Node route (app/api/parse/route.ts)

export const runtime = 'nodejs'
import { NextResponse } from 'next/server'
import { parse } from '@uchina-systems/csv-to-json'

export async function POST(req: Request) {
  const bytes = new Uint8Array(await req.arrayBuffer())
  const json = parse(bytes, { headers: true, caseStyle: 'pascal' })
  return NextResponse.json(JSON.parse(json))
}

API

export type CaseStyle = 'pascal' | 'camel' | 'snake' | 'kebab' | 'title' | 'lower' | 'upper'

export interface ParseOptions {
  headers?: boolean            // default: true
  delimiter?: number           // default: 44 (",")
  caseStyle?: CaseStyle        // optional key normalization (headers only)
}

// Returns JSON string of an array of objects
export function parse(bytes: Uint8Array, options?: ParseOptions): string

// Returns parsed objects directly
export function parseToArray(bytes: Uint8Array, options?: ParseOptions): Array<Record<string, string>>

Case normalization

  • Examples with caseStyle: 'pascal'
    • "YouTube link" → "YouTubeLink"
    • "IMPORT" → "Import"
    • Mixed-case tokens like "YouTube" are preserved

Browser demo

npm run demo
# Opens http://localhost:5173/examples/browser.html

.NET usage (C#)

This repo includes a .NET wrapper and a Rust C ABI. You can use the packaged DLL to call the same parser from C#.

Quick start (local build)

# Build native library for your current platform and copy into runtimes/
node scripts/build-dotnet.mjs

# Create the NuGet package (includes the native library under runtimes/<rid>/native)
dotnet build ./dotnet/Csvjson/Csvjson.csproj -c Release
# or: dotnet pack ./dotnet/Csvjson/Csvjson.csproj -c Release

Then reference the produced package (YourScope.Csvjson.0.1.0.nupkg) in your .NET solution, or reference the project directly.

C# example

using System.Text;
using Csvjson;

var csv = "YouTube link,IMPORT\nhttps://yt.com,YES\n";
var bytes = Encoding.UTF8.GetBytes(csv);
var json = Parser.Parse(bytes, headers: true, delimiter: null, caseStyle: "pascal");
Console.WriteLine(json);

Notes

  • The NuGet currently includes a macOS arm64 native library when built on that platform. To support more RIDs (linux-x64, win-x64, etc.), repeat the native build on those platforms (or cross-compile) and place the outputs under dotnet/Csvjson/runtimes/<rid>/native/ before packing.
  • NPM package automatically selects WASM (Edge/Browser) or the native add-on (Node) via conditional exports.

Build from source (npm)

npm run build

License

MIT OR Apache-2.0