smol-toml is a JavaScript and TypeScript library designed for parsing and serializing TOML (Tom's Obvious, Minimal Language) documents. Currently at version 1.6.1, it offers a small, fast, and highly compliant implementation of the TOML specification, supporting the latest TOML 1.1.0 standard since version 1.6.0. It maintains a regular release cadence with recent updates addressing security vulnerabilities and feature enhancements. Differentiating itself from other often outdated or unmaintained TOML parsers in the JavaScript ecosystem, smol-toml is noted as the most downloaded TOML parser on npm, actively used in production systems. While generally robust, it explicitly notes some non-compliance with the `toml-test` suite for performance reasons, such as not rejecting invalid UTF-8 or certain invalid dates. It also provides options for handling integers as BigInts to prevent precision loss, a feature introduced in v1.4.0.
npm install smol-tomlVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a TOML string into a JavaScript object and then stringifying the object back into a TOML string, including options for BigInt parsing.
Review any snapshot tests or external integrations that parse or compare `smol-toml` stringify output. Adjust expectations for the more compact TOML format.
Upgrade to smol-toml version 1.6.1 or later (`npm install smol-toml@latest`).
When parsing, use `parse(tomlString, { parseBigInt: true })` to interpret all integers as BigInts. This feature was introduced in v1.4.0.Ensure that arrays intended for serialization with `stringify` do not contain `undefined` or `null` elements. Filter these values out before passing the object to `stringify`.
Before stringifying, ensure that the object only contains primitive types, arrays, and plain objects. Remove or transform any functions, classes, or symbols that might be present.
Filter `undefined` or `null` values from arrays before passing the object to `smol-toml`'s `stringify` function. Example: `stringify({ my_array: [1, null, 3].filter(item => item !== null) })`.When parsing TOML, enable BigInt support by calling `parse(tomlString, { parseBigInt: true })`. This will parse large integers as JavaScript `BigInt` types, preserving their full precision.Before calling `stringify`, ensure that the object only contains serializable primitive types, arrays, and plain objects. Remove or transform any `Function`, `Class`, or `Symbol` properties.
No dependency data recorded yet.