Skip to content

Minify JSON files fast! Supports Comments. Uses D, C, and AVX2 and SSE4_1 SIMD.

License

Notifications You must be signed in to change notification settings

aminya/minijson

Repository files navigation

minijson

Minify JSON files fast! Written in D.

1.5 times faster than jsonminify.

CI

Installation

Nodejs

npm install @aminya/minijson

Dub

dub fetch minijson --config=library
# or
dub fetch minijson --config=executable

CLI Usage

Usage: minify json
    minijson --file file1.json --file file2.json
    minijson --string '{"some_json": "string_here"}'

     --file an array of files to minify
   --string a json string to minify
-h   --help This help information.

Node API

import { minifyFiles, minifyString } from "minijson"

// minify the files in-place and in parallel
await minifyFiles(["file1.json", "file2.json"])

// minify the given string
const minifiedString = minifyString(`{"some_json": "here"}`)

Note: in the Nodejs API, prefer minifyFiles over other functions, as it minifies the files in parallel with the least amount of resources.

D API

import minijson: minifyString, minifyFiles;

// minify the given string
const minifiedString = minifyString(`{"some_json": "here"}`);

// minify the files in-place and in parallel
minifyFiles(["file1.json", "file2.json"]);

Benchmarks

❯ node .\benchmark\native-benchmark.mjs
38,823 ms

❯ node .\benchmark\js-benchmark.mjs
58,686 ms

Contributing

pnpm install
pnpm run build.node

License

The project is licensed under MIT. It was inspired by fkei/JSON.minify.