# json-xz

> Easily read and write XZ compressed JSON or raw files

Latest version **1.0.1** (published 2023-05-15) · LGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install json-xz
pnpm add json-xz
yarn add json-xz
bun add json-xz
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-05-15 |
| First published | 2023-05-15 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Isaac Nygaard |
| Maintainers | azmisov |
| Keywords | json, fs, promise, filesystem, xz, compression, node |

## Links

- npm: https://www.npmjs.com/package/json-xz
- Repository: https://github.com/Azmisov/json-xz
- Homepage: https://github.com/Azmisov/json-xz#readme
- Issues: https://github.com/Azmisov/json-xz/issues
- npm.io page: https://npm.io/package/json-xz

## Dependencies (1)

- [xz](https://npm.io/package/xz.md) ^2.0.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-05-15
- 1.0.0 — 2023-05-15

## README

# json-xz

Small library to read and write [XZ](https://en.wikipedia.org/wiki/XZ_Utils) compressed JSON files.
XZ compression gives you some of the highest compression ratios, while still being very fast. This
utilizes the [xz](https://www.npmjs.com/package/xz) library, which is a multithreaded C++ binding to
liblzma.

[npm package](https://www.npmjs.com/package/json-xz) |
[GitHub source code](https://www.github.com/Azmisov/json-xz)

## Installation

```
npm i json-xz
```

A minified version is provided as `jsonxz.min.js`. A bundle is not provided, as `xz` uses `node-gyp`
to compile C++ bindings. See documentation for `node-gyp` if the `xz` dependency is not installing.

## Usage

```js
import jsonxz from "json-xz";

const data = await jsonxz.read("./data.json.xz");
// compression level is 1 (least/fastest) to 9 (most/slowest); default is 6
await jsonxz.write("./data.json.xz", data, 6);
```

For convenience, you can also read/write raw data from XZ compressed files. You can use this
interface if you want to stringify the JSON yourself, or perhaps use some other format besides JSON:

```js
const raw_data_str = await jsonxz.readFile("./data.xz");
// you can also write a Buffer or Uint8Array
await jsonxz.writeFile("./data.xz", raw_data_str, 6);
```

This gives ~27% size reduction for some example data, and compression generally seems to be around
that for different JSON files.

---
_Source: https://npm.io/package/json-xz · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
