Compact YAML, TOML, JSONC, JSON5 and INI parser and serializer
npm install confbox



Parsing and serialization utils for YAML (js-yaml), TOML (smol-toml), JSONC (jsonc-parser), JSON5 (json5), INI (ini) and JSON.
⨠Zero dependency and tree-shakable
⨠Types exported out of the box
⨠Preserves code style (indentation and whitespace)
> [!TIP]
> Use unjs/c12 for a full featured configuration loader!
Install package:
``sh⨠Auto-detect
npx nypm install confbox
Import:
ESM (Node.js, Bun, Deno)
`js
import {
parseJSON5,
stringifyJSON5,
parseJSONC,
stringifyJSONC,
parseYAML,
stringifyYAML,
parseJSON,
stringifyJSON,
parseTOML,
stringifyTOML,
parseINI,
stringifyINI,
} from "confbox";
`CDN (Deno and Browsers)
`js
import {
parseJSON5,
stringifyJSON5,
parseJSONC,
stringifyJSONC,
parseYAML,
stringifyYAML,
parseJSON,
stringifyJSON,
parseTOML,
stringifyTOML,
parseINI,
stringifyINI,
} from "https://esm.sh/confbox";
`$3
Converts an INI string into an object.
Note: Style and indentation are not preserved currently.
$3
Converts a JSON string into an object.
Indentation status is auto-detected and preserved when stringifying back using
stringifyJSON$3
Converts a JSON5 string into an object.
$3
Converts a JSONC string into an object.
$3
Converts a TOML string into an object.
$3
Converts a YAML string into an object.
$3
Converts a JavaScript value to an INI string.
Note: Style and indentation are not preserved currently.
$3
Converts a JavaScript value to a JSON string.
Indentation status is auto detected and preserved when using value from parseJSON.
$3
Converts a JavaScript value to a JSON5 string.
$3
Converts a JavaScript value to a JSONC string.
$3
Converts a JavaScript value to a TOML string.
$3
Converts a JavaScript value to a YAML string.
Contribution
Local development
- Clone this repository
- Install the latest LTS version of Node.js
- Enable Corepack using
corepack enable
- Install dependencies using pnpm install
- Run tests using pnpm dev or pnpm test`Published under the MIT license.
Made by @pi0 and community đ
---
_đ¤ auto updated with automd_