🗜️ libuntar Demo

Extract and view files from .tar.gz archives in the browser using native JavaScript APIs.

Try it out: Upload a .tar.gz file or use the sample file provided below.

Upload or Load Archive

Usage

Install from npm (or copy the source files directly):

npm install libuntar

Extract a .tar.gz archive

import { untgz, untar } from 'libuntar/untgz';

const blob = await (await fetch('archive.tar.gz')).blob();
const { arrayBuffer, entries } = await untgz(blob);

// List entries
entries.forEach((e) => console.log(e.name, e.size, e.isFile));

// Read one file
const entry = entries.find((e) => e.name === 'readme.txt');
const text = new TextDecoder().decode(untar(entry, arrayBuffer));

Extract a raw .tar archive

import { getEntries, untar } from 'libuntar';

const arrayBuffer = await (await fetch('archive.tar')).arrayBuffer();
const entries = getEntries(arrayBuffer);
const data = untar(entries[0], arrayBuffer);

See the full README and API reference for details.