Skip to main content
← Guides

Guide

SheetJS vs ExcelJS vs node-xlsx: Node Excel Files

Updated PkgPulse Team11 min read
0

SheetJS vs ExcelJS vs node-xlsx for Node.js Excel files: compare formats, styling, streaming APIs, installation, licenses, and a reproducible large-file test.

Contents

One-minute guide summary

AI-narrated explainer with burned-in captions.

Continue with the full guide

TL;DR

Choose SheetJS Community Edition for format conversion and tabular imports, ExcelJS for styled XLSX reports or its Node streaming reader and writer, and node-xlsx for a small array-based API. Install SheetJS from its documented distribution. Do not assume that writing formula text calculates results, or that an ExcelJS document workbook becomes memory-efficient merely because its input is a file stream.

Quick decision table

RequirementStart withImportant constraint
XLS, XLSX, ODS or CSV inputSheetJS CETest format-specific features with real files
Styled XLSX reportExcelJSVerify the exact feature in the installed release
Row-oriented XLSX import in NodeExcelJS streaming readerShared strings and application buffering affect memory
Simple arrays into a workbooknode-xlsxSmall API does not imply small memory use
Browser workflowEvaluate the document APIsNode streaming APIs are a separate capability
Formula calculation or chart-heavy templatesValidate a dedicated solutionRead/write support does not establish feature preservation

This is a task-based decision matrix. It does not rank parsers by popularity or claim a universal memory advantage.

SheetJS: distribution and format coverage

The official Node installation instructions use SheetJS CDN tarballs. Do not assume an unqualified registry install delivers the release shown in those instructions. Pin the distribution in your dependency manifest and commit the lockfile.

For example, the documented tarball used in this guide's fixture is:

bun add https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz

The import name remains xlsx. The command is a pinned example, not a promise that this version will remain the newest release. Check the official instructions when upgrading.

SheetJS's format table documents read and write coverage separately. It includes XLSX, legacy XLS, ODS and CSV. Choose it when the input format is the deciding factor, then test the features you need to retain. Being able to open a workbook does not mean that every embedded feature survives a round trip.

The Node ESM build requires filesystem support to be registered before calling readFile or writeFile:

import * as XLSX from 'xlsx';
import * as fs from 'fs';
XLSX.set_fs(fs);

const workbook = XLSX.readFile('input.xlsx');
const sheet = workbook.Sheets[workbook.SheetNames[0]];
const rows = XLSX.utils.sheet_to_json(sheet, {
  header: 1,
  defval: null,
  raw: true,
});

Here header: 1 returns arrays. It does not return typed objects keyed by the first row. Decide whether your import contract uses positional cells or named columns before assigning a TypeScript type.

A generic type argument can describe an expected row, but it cannot validate uploaded data. Check required headers, accepted cell types and missing values before passing rows into application logic.

ExcelJS: document workbooks and streaming are different APIs

ExcelJS exposes a document workbook model for manipulating worksheets, cells and styles. It also exposes separate streaming XLSX reader and writer classes. Use the API that matches the operation rather than treating every read from a stream as incremental processing.

The document pattern below loads a workbook model:

import ExcelJS from 'exceljs';

const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile('input.xlsx');
const sheet = workbook.worksheets[0];
sheet.eachRow(row => {
  console.log(row.values);
});

Calling eachRow after that read iterates an already-loaded worksheet. Replacing readFile with workbook.xlsx.read(fileStream) does not turn this model into the streaming reader. That distinction matters more than whether the source is called a stream.

For report generation, use document workbooks when you need to revisit rows and adjust presentation. Keep the logic that selects report data separate from workbook construction. Then a test can validate business totals without opening an XLSX file, while a small output test checks formatting and cell placement.

The ExcelJS documentation describes row commits and streaming limitations. Committed rows are not available for arbitrary later edits. Design totals, cross-row calculations and merged regions with that lifecycle in mind.

Do not use the repository's default-branch README as proof that every mentioned feature is present in a published package. In particular, validate pivot-table requirements against the exact version you install. This guide does not promise chart creation or complete pivot-table support.

node-xlsx: a smaller interface over spreadsheet handling

node-xlsx exposes parsing and building around arrays of sheet records. This fits a job that reads a simple table, changes values, and writes another workbook.

import xlsx from 'node-xlsx';
import { writeFileSync } from 'node:fs';

const sheets = xlsx.parse('input.xlsx');
const rows = sheets[0].data;
const output = xlsx.build([
  { name: 'Output', data: rows, options: {} },
]);
writeFileSync('output.xlsx', output);

The wrapper uses SheetJS functionality. It should not be described as an independent parser with a different memory model. Inspect the installed artifact and lockfile when deciding which underlying code reaches production. A dependency can also be bundled into a published artifact rather than appearing as a runtime dependency entry.

The array interface removes workbook-specific decisions from the call site. That helps when the data contract is simple. It also makes it easy to forget the distinction between cell values, displayed strings and workbook features. If your requirements grow to include detailed formatting, reconsider whether a row-array abstraction still fits.

Do not describe node-xlsx as XLSX-only solely because of its name. Its README describes the underlying parser and supported formats. For a format-sensitive project, use fixtures to establish the wrapper behavior you rely on.

Decision matrix: preserve values, presentation or behavior?

Acceptance targetFixture to keepWhat to compare
Tabular importEmpty cells, booleans, dates and identifiersApplication values after validation
Legacy conversionA real XLS or ODS sampleCell values and required sheet structure
Styled reportHeader, currency format and merged regionOutput in the spreadsheet program readers use
Formula templateFormula plus cached valueFormula text and recalculation behavior
Large importRepeated and unique stringsRow count, checksum, time and process memory
Existing workbook rewriteA copy with required featuresRequired features after save and reopen

Start from the acceptance target. A plain data export does not need all of Excel's presentation features. A finance template cannot be validated by counting rows alone.

Keep identifiers such as account codes as strings when leading zeros matter. Decide how dates, time zones, percentages and currency values cross the import boundary. A spreadsheet display string and the underlying numeric value serve different purposes.

For formulas, storing an expression and evaluating it are separate operations. Test whether the receiving application recalculates and whether a consumer without a calculation engine reads a cached result. Do not advertise a formula-capable reader as an Excel calculation engine.

A reproducible large-file memory check

Use the same fixture and run each parser in its own process. The code below creates a workbook with numeric row IDs and unique string cells, then verifies the row count and ID checksum. It uses the actual ExcelJS streaming reader rather than a document workbook followed by eachRow.

Install a separate test project so this exercise does not change the application's dependencies:

bun init -y
bun add exceljs@4.4.0 node-xlsx@0.25.0 \
  https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz

Save the following as bench.cjs:

const ExcelJS = require('exceljs');
const XLSX = require('xlsx');
const nodeXlsx = require('node-xlsx').default;
const { performance } = require('node:perf_hooks');
const mode = process.argv[2];
const rows = Number(process.argv[3] || 100000);
const file = 'fixture.xlsx';
async function main() {
  const start = performance.now();
  let count = 0;
  let checksum = 0;
  if (mode === 'generate') {
    const wb = new ExcelJS.stream.xlsx.WorkbookWriter({filename:file});
    const ws = wb.addWorksheet('Data');
    for (let i=0; i<rows; i++) {
      ws.addRow([i, ...Array.from({length:9}, (_,c)=>`value-${i}-${c}`)]).commit();
    }
    await wb.commit();
    return;
  }
  const consume = values => { count++; checksum += Number(values[0]); };
  if (mode === 'sheetjs') {
    const wb = XLSX.readFile(file);
    for (const row of XLSX.utils.sheet_to_json(wb.Sheets.Data, {header:1})) consume(row);
  } else if (mode === 'exceljs') {
    const reader = new ExcelJS.stream.xlsx.WorkbookReader(file, {
      sharedStrings:'cache', hyperlinks:'ignore', styles:'ignore',
    });
    for await (const ws of reader) {
      for await (const row of ws) consume(row.values.slice(1));
    }
  } else if (mode === 'node-xlsx') {
    for (const row of nodeXlsx.parse(file)[0].data) consume(row);
  } else throw new Error('Unknown mode');
  if (count !== rows || checksum !== rows*(rows-1)/2) throw new Error('Incorrect result');
  console.log(JSON.stringify({mode, count, checksum,
    elapsedMs:performance.now()-start, maxRssKiB:process.resourceUsage().maxRSS}));
}
main().catch(error => { console.error(error); process.exitCode=1; });

Run the generator once, then each read separately:

node bench.cjs generate 100000
node bench.cjs sheetjs 100000
node bench.cjs exceljs 100000
node bench.cjs node-xlsx 100000

The fixture was executed with the pinned packages on Linux under Node 26.13.0. All three readers returned 100,000 rows and the expected checksum, 4,999,950,000. This checks a plain single-sheet workbook, not feature preservation. It does not establish a speed or memory winner for your files.

maxRssKiB uses Node's process resource usage report. It includes process overhead and imports. This intentionally identical harness imports all three libraries in every reader process. It measures the job as written, not the minimum footprint of each library alone. For a production capacity test, use separate minimal entry points that match your deployment.

Repeat runs and record runtime, operating system, package versions, fixture bytes and cache conditions. Extend the fixture with shared strings, styles, multiple sheets and your normal data distribution. Keep the row count and checksum assertions so a fast result cannot hide skipped data.

Do not infer peak memory from heapUsed at the end of a job. The process may have already released objects, and heap excludes some native allocations. Do not extrapolate a linear memory multiplier from compressed XLSX file size either.

Memory control belongs in application code too

A streaming reader can still feed an array that grows until the entire dataset is retained. Process rows in bounded batches and await the database or output operation before accumulating more. Measure the full job with those operations included.

Shared-string caching, styles and workbook structure can also affect memory. The fixture makes its reader options explicit. Change them only after deciding which workbook information the application needs.

For streaming writes, commit rows when they are complete and finish the workbook before treating the file as ready. Handle both parsing errors and downstream failures. An interrupted export should not be delivered as a completed report.

For browser workflows, test the document APIs separately. A Node streaming example is not evidence that the same API works in a browser bundle. Measure the downloaded artifact if client bundle size matters rather than copying an old package-size estimate.

For an export that delivers several completed workbooks together, compare JSZip and fflate for browser archives to see where the ZIP writer holds output in memory.

Untrusted uploads and type safety

Validate filenames and size limits before parsing, then validate the resulting schema. A compressed file's size is not a complete bound on its expanded memory use. Run expensive import jobs with resource and time limits appropriate to the deployment.

Keep a small regression collection of accepted, rejected and malformed files. Return an actionable import error without exposing internal paths or stack traces. Do not silently coerce an invalid identifier into a number because it happens to parse.

A TypeScript annotation documents what callers expect. It does not establish that a cell contains a string, that a date is valid, or that headers are unique. Make those checks explicit at the import seam and pass validated application records to the rest of the code.

Treat content loaded from a workbook as untrusted when rendering HTML or building queries. When writing values back to spreadsheets, decide whether a string beginning with a formula prefix should remain literal text. Test that decision in the target spreadsheet application.

Licensing and dependency review

SheetJS CE uses Apache-2.0. ExcelJS's published metadata lists MIT. node-xlsx 0.25.0 lists Apache-2.0, not MIT. Verify the licenses and notices in the artifacts you ship, including bundled code. A small wrapper interface does not remove obligations for its included code.

Do not infer SheetJS Pro pricing or entitlement from the CE documentation. If the project needs commercial functionality, obtain the applicable feature and licensing terms. This comparison does not quote a Pro price or treat all streaming as a paid-only feature: CE documents stream exports for supported output types.

SheetJS's stream export documentation includes CSV, HTML and JSON output. Those operations are distinct from an incremental XLSX workbook reader or writer. Choose by the exact input and output operation instead of a single “streaming: yes/no” cell.

When to use which

Choose SheetJS CE when format coverage and converting workbook data into application records are the main requirements. Pin its documented distribution and validate imported rows.

Choose ExcelJS for cell-oriented XLSX report construction or its explicit Node streaming APIs. Test presentation separately from row processing and verify required features in the pinned release.

Choose node-xlsx when arrays of sheet data are the right interface. Keep it for simple transformations, and reassess when you need workbook-specific editing or tight memory control.

FAQ

Does ExcelJS calculate formulas?

Its documentation separates formula expressions from their results and says a result must be supplied. Do not expect it to calculate a workbook like Excel.

Is all SheetJS streaming restricted to Pro?

No. CE documents stream exports, including CSV, HTML and JSON. That does not mean CE incrementally reads and writes arbitrary XLSX workbooks.

Methodology

Official documentation and published metadata support the capability and license discussion. The embedded fixture supplies a repeatable correctness and capacity check. Old npm download counts, undocumented memory ratios and claimed Apple hardware benchmarks have been removed.

Source notes

See PapaParse vs csv-parse vs fast-csv for CSV-only work, Ajv vs Zod vs Valibot for validation choices, and Node test vs Vitest vs Jest for regression fixtures.