Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 932 Bytes

File metadata and controls

43 lines (28 loc) · 932 Bytes
description Modern alternatives to toml for TOML parsing and stringifying

Replacements for toml

toml appears to be unmaintained and has known spec-compliance issues.

smol-toml

smol-toml is a well maintained TOML v1.1.0 parser/stringifier with full spec compliance, comment/AST support, and no deps.

Parse (load):

import toml from 'toml' // [!code --]
import { parse } from 'smol-toml' // [!code ++]

const obj = toml.parse(src) // [!code --]
const obj = parse(src) // [!code ++]

Stringify:

import { stringify } from 'smol-toml'

const text = stringify(obj)

Bun TOML API (native)

Native TOML parsing is supported in Bun.

Example:

import toml from 'toml' // [!code --]
import { TOML } from 'bun' // [!code ++]

toml.parse(src) // [!code --]
TOML.parse(src) // [!code ++]