Skip to content

JSON Utils

Terminal window
pnpm add @theholocron/json-utils
import { stringifyJson } from "@theholocron/json-utils";
stringifyJson({ a: 1 }); // '{\n "a": 1\n}\n'
// rewrite a file without reformatting it
const original = await readFile("package.json", "utf8");
const pkg = JSON.parse(original);
pkg.version = "2.0.0";
await writeFile("package.json", stringifyJson(pkg, { like: original }));

The full API reference is generated from the package’s TSDoc comments.