smol-toml
A small, fast, spec-compliant TOML parser and serializer for JavaScript
Repository Health
Technical Analysis
smol-toml is a compact TOML v1.1.0 parser and serializer built to fix a gap in the JavaScript ecosystem, where most existing TOML libraries were outdated, unmaintained, or non-compliant with the spec. It exposes just two core functions — parse() and stringify() — plus a TomlDate helper class that correctly represents all four TOML date/time variants (offset date-time, local date-time, local date, local time) using an extended native Date object.
Despite its small surface area, smol-toml passes the vast majority of the official toml-test conformance suite and benchmarks faster than nearly every competing JS TOML parser on both small and multi-megabyte documents, while offering opt-in BigInt support for integers beyond the 53-bit safe range that plain JavaScript numbers can represent.
What You Get
- A
parse()function converting TOML text into plain JavaScript objects, passing nearly all of the officialtoml-testconformance suite - A
stringify()function that serializes JS objects back to TOML, correctly round-tripping integers vs floats where possible - A
TomlDateclass distinguishing Offset Date-Time, Local Date-Time, Local Date, and Local Time, each queryable viaisDateTime()/isDate()/isTime()/isLocal() - Opt-in BigInt integer parsing (
integersAsBigInt: trueor"asNeeded") for values beyond JavaScript’s 53-bit safe integer range - A
numbersAsFloatstringify option for end-to-end type preservation between BigInt integers and floating-point numbers - Best-in-class benchmarked performance among JS TOML parsers on both spec-example and multi-megabyte documents
Common Use Cases
- Parsing
pyproject.toml-style or Cargo-style configuration files inside JavaScript/TypeScript tooling - Reading and writing TOML-based config for CLIs, build tools, and language-server implementations written in JS
- Round-tripping TOML documents where integer-vs-float type distinctions and TOML date semantics must be preserved
- Replacing an unmaintained or non-conformant legacy TOML parser in an existing Node.js codebase
- High-throughput parsing of large TOML documents where parser performance is a meaningful bottleneck
Under The Hood
Architecture: The library is deliberately small and flat — src/parse.ts drives a hand-written recursive-descent-style tokenizer/parser that delegates primitive value parsing to src/primitive.ts (strings, numbers, booleans) and src/date.ts (the four TOML date/time forms), while src/struct.ts assembles parsed key/value pairs into nested objects and arrays-of-tables; src/stringify.ts performs the inverse walk, and src/extract.ts plus src/util.ts hold small shared helpers, with src/error.ts defining a dedicated parse-error type carrying line/column context. Tech Stack: Pure TypeScript with zero runtime dependencies, built and tested via a pnpm workspace (pnpm-workspace.yaml) with a Justfile/mise.toml for task running, and benchmarked against seven competing parsers using the mitata benchmarking library. Code Quality: Correctness is validated against the official toml-lang/toml-test conformance suite via run-toml-test.bash, with explicitly documented, deliberate exceptions (e.g. invalid UTF-8 and some invalid dates are accepted for performance reasons) rather than silent gaps, plus a dedicated test/ directory of unit tests alongside the conformance harness. API Design: The public surface is intentionally minimal — parse(), stringify(), and TomlDate — mirroring the ergonomics of the built-in JSON global (import TOML from 'smol-toml'; TOML.stringify(...)), which keeps the learning curve near zero for anyone already familiar with JSON.parse/JSON.stringify.
Used by 17 apps in this directory
PeerTube
Social Media
A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.
Rudel
Developer Tools
Open-source analytics for Claude Code and Codex sessions — a CLI uploads session transcripts to a self-hostable dashboard tracking token usage, session duration, activity patterns, and model usage.
sigle
Blogging
A decentralized, open-source writing platform that permanently stores your stories on the Stacks blockchain and Arweave — where Web3 content creators own their words forever.
Spacedrive
Collaboration · File Storage
One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.
Stirling PDF
Digital Signiture · Productivity
The open-source PDF platform you can run anywhere — edit, convert, sign, and automate PDFs without sending files to external servers.
Suna
AI Agents
Turn your company into a git repo — one config, one command center, a workforce of AI agents that runs the real work around the clock.
Supabase
Authentication · Databases · Developer Tools
The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.
TensorZero
Ab Testing Experimentation · AI Development · Monitoring
TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.