tar

The battle-tested tar archive library that powers npm itself, with hardened extraction against path-traversal and symlink attacks.

Library
npm
v7.5.22
924 stars
BlueOak-1.0.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
49 /100 Fair
Development Activity 16
Maintenance 20
Community 80
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 82
Code Quality 85
Innovation 78
Learning Curve 80

tar (published to npm as tar, developed as node-tar) is a fast, full-featured implementation of the tar archive format for Node.js. It mirrors the behavior of the Unix tar(1) command, exposing the same five core operations — create, extract, list, replace, and update — through both a low-level streaming API and a high-level convenience API with single-letter aliases familiar to anyone who has used the command line tool.

Because it is the archive library underneath npm’s own package installation pipeline, tar has been hardened over more than a decade against a wide range of filesystem attacks: path-traversal entries, symlink-based writes outside the extraction target, absolute path abuse, and malicious device/FIFO entries are all rejected or neutralized by default. It supports gzip, brotli, and zstd compression natively via minizlib, and every operation can run synchronously, asynchronously with callbacks, as a Promise, or as a raw stream depending on how it’s invoked.

What You Get

  • Five core operations — create (c), extract (x), list (t), replace (r), and update (u) — each usable as sync, async/Promise, or stream, mirroring tar(1) CLI semantics
  • Security-hardened extraction: rejected .. path traversal, blocked symlink/hardlink escapes outside the extraction root, absolute paths rewritten to relative, and device/FIFO entries never extracted
  • Built-in gzip, brotli, and zstd compression/decompression via minizlib, auto-detected on read and configurable on write
  • A path-reservation system that safely serializes conflicting filesystem operations during parallel extraction (e.g. a file being swapped for a symlink mid-write)
  • Granular warn/error event system with typed error codes (TAR_ENTRY_INVALID, TAR_BAD_ARCHIVE, etc.) so callers can distinguish recoverable per-entry issues from fatal archive corruption
  • Full TypeScript types for every option surface, published as dual ESM/CJS builds via tshy

Common Use Cases

  • Packaging and unpacking npm-style package tarballs during install/publish workflows
  • Backing up or archiving directory trees to a .tgz/.tar file from a Node.js build or deploy script
  • Extracting third-party or user-uploaded tarballs safely in a server context where the archive source isn’t trusted
  • Streaming tar creation directly into an HTTP response or another pipe without touching disk
  • Replacing or appending entries in an existing archive without a full rebuild

Under The Hood

Architecture — tar is organized as a set of composable Minipass transform/writable streams rather than a monolithic library: Pack/PackSync (src/pack.ts) turn a list of paths into a tar byte stream by walking the filesystem and delegating each entry to WriteEntry (src/write-entry.ts); Parser (src/parse.ts) is the inverse, a writable stream that consumes tar bytes and emits ReadEntry objects (src/read-entry.ts) as it decodes 512-byte headers via the Header/Pax classes (src/header.ts, src/pax.ts); Unpack/UnpackSync (src/unpack.ts, ~1,100 lines) subclass the parser and materialize entries onto the filesystem, coordinating a PathReservations queue (src/path-reservations.ts) so concurrent async writes to related paths don’t race. The five public verbs in create.ts, extract.ts, list.ts, replace.ts, and update.ts are thin orchestrators built with a shared makeCommand helper (src/make-command.ts) that normalizes the sync/async/callback/Promise/stream calling conventions into one implementation per verb.

Tech Stack — Written entirely in TypeScript (44.7% of source, compiled JS 55.2%) and built with tshy to publish dual ESM/CommonJS output plus .d.ts types from a single source tree. Runtime dependencies are all from the same maintainer’s ecosystem: minipass (the stream primitive everything is built on), minizlib (gzip/brotli/zstd via Node’s zlib bindings), @isaacs/fs-minipass (filesystem streams), chownr (recursive ownership changes), and yallist (linked-list queue used internally). No external framework dependencies; targets Node.js >=18.

Code Quality — Tested with tap across 30+ dedicated test files (141+ individual test cases found in test/), including targeted regression tests for named security advisories (ghsa-8qq5-rm4j-mr97.ts, ghsa-r6q2-hw4h-h46w.ts), fixture-driven header/parse tests, and a .taprc configured with typecheck: true and a coverage map (map.js). Linting is enforced via oxlint plus oxlint-tsgolint for type-aware rules, formatting via prettier, and the codebase uses symbol-keyed private-ish fields (Symbol('...')) throughout its stream classes for encapsulation instead of relying on TS private alone — a defensive pattern consistent with the project’s security-first posture.

API Design — The library deliberately mirrors tar(1) CLI semantics: every high-level function accepts (options, paths, callback?), single-letter aliases (c/x/t/r/u) map directly to Unix tar flags, and the same option object supports sync: true, a file path, or neither (returning a stream) — one mental model covers all five operations. The cost of that flexibility is a large, densely-typed TarOptions interface (500+ lines in options.ts) with many optional fields and overload variants, which raises the learning curve for anyone who wants more than the common create/extract path shown in the README’s copy-paste examples.

Used by 52 apps in this directory

TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,754

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
88
Repo Health
82
Technical
65
Dependency
Built with
TypeScript 45%
Rust 43%
Updated 6 days ago
TypeScript
96%
MIT

deepseek-harness

AI Agents · AI Development · Developer Tools

259,694

An open-source, plugin-based agent harness from DeepSeek AI that runs coding and automation agents across web, desktop, CLI, and SDK surfaces.

View details
82
Repo Health
89
Technical
73
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
Go
75%
MIT

Digger

Automation · Developer Tools · Devops

5,057

Run Terraform and OpenTofu natively inside your existing CI pipeline — no separate runners, no third-party secrets, no extra compute costs.

View details
78
Repo Health
73
Technical
66
Dependency
Built with
Go 75%
TypeScript 15%
Updated 1 weeks ago
TypeScript
80%
Other

Directus

CMS · Low Code Platforms

38,629

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
93
Repo Health
82
Technical
76
Dependency
Built with
TypeScript 80%
Vue 19%
Updated 1 weeks ago
TypeScript
94%
AGPL 3.0

Element Web

Collaboration · Team Chat

13,609

A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.

View details
96
Repo Health
83
Technical
64
Dependency
Built with
TypeScript 94%
Updated 1 weeks ago
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,443

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
57
Repo Health
90
Technical
61
Dependency
Built with
Java 34%
TypeScript 27%
Scala 26%
Updated 2 months ago
PHP
66%
AGPL 3.0

EspoCRM

CRM · Ecommerce · Marketing

3,514

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
97
Repo Health
72
Technical
64
Dependency
Built with
PHP 66%
JavaScript 23%
Updated 1 weeks ago
TypeScript
74%
Apache 2.0

Fern

Developer Tools

3,822

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript 74%
Updated 6 days ago
Rust
89%
Apache 2.0

Graphite

Code Editors · Design Tools

27,703

A free, open source procedural 2D design tool that unifies vector, raster, motion graphics, and generative art in a single node-based nondestructive workflow.

View details
84
Repo Health
77
Technical
70
Dependency
Built with
Rust 89%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers