hucre

hucre

WHAT IS IT?

hucre is a spreadsheet engine written in pure TypeScript with zero dependencies. It reads and writes XLSX, CSV, ODS, JSON, NDJSON and XML, and reads legacy XLS and XLSB on top. The core touches no Node APIs (fs, crypto, Buffer) and no eval, so the same package runs on Node 24+, Deno, Bun, a browser, a Cloudflare Worker or a Vercel Edge Function.

WHY IS IT INTERESTING?

  • Zero dependencies and tree-shakeable imports: every format has its own subpath. parseCsv + writeCsv from hucre/csv weigh 3.7 KB gzipped, readXlsx alone 34 KB, the whole barrel 129 KB. Those numbers sit in a size budget that fails CI as soon as one entry grows past it
  • Streaming in both directions: streamXlsxRows is an async generator that parses the ZIP front-to-back straight from a ReadableStream, with a row cap and an A1 range filter. writeXlsxStream pulls from any iterable - a database cursor, another stream - and peak memory stays flat as the row count grows
  • Two paths, kept apart on purpose: openXlsx/saveXlsx copies every part it does not regenerate byte-for-byte, so charts, VBA macros and themes survive an edit. readXlsx/writeXlsx is the authoring path and rebuilds the workbook from the model
  • Writing covers the awkward parts: cell styles, font-aware auto column widths (CJK double-width characters included), freeze and split panes, auto-filter, data validation, hyperlinks, images, comments, tables, conditional formatting with its dxf styles, sparklines and Excel 2024 native checkboxes
  • Schema validation in the box: validateWithSchema coerces types and applies required, pattern, min/max, enum and custom validators, then hands back clean objects on one side and a list of errors (row, field, value) on the other
  • Unified API and a CLI: read() detects the format from magic bytes or the first character, write() emits nine formats, and npx hucre convert|inspect|validate does the same from a terminal, stdin and stdout included

USE CASES

  • Generating a styled Excel export from an API route or an edge function without adding a single dependency
  • Ingesting a multi-million-row customer file as a stream, with each row checked against a schema on the way through
  • Editing one cell in a business workbook full of charts and macros without breaking the rest of the file
  • Converting a legacy XLS or a CSV to XLSX, Markdown or NDJSON in a single command