npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tomlite

v0.1.1

Published

A minimal, robust, and safe TOML parser and serializer for JavaScript and TypeScript

Readme

tomlite - A small, safe TOML parser for JS/TS

npm version

日本語のREADME

This library is a small, safe parser and serializer focused on the essential features of TOML. It has no dependencies. Full compliance with the TOML specification is not a goal; unsupported syntax results in an error (TomlError).

Usage

Importing tomlite gives you the parse and stringify functions.

import { parse, stringify, TomlError } from 'tomlite';

const data = parse(`
title = "Example"

[owner]
name = "Tom"
dob = 1979-05-27T07:32:00-08:00

[[fruits]]
name = "apple"
`);
// { title: 'Example', owner: { name: 'Tom', dob: '1979-05-27T07:32:00-08:00' }, fruits: [ { name: 'apple' } ] }

const toml = stringify({ title: 'Example', server: { port: 8080 } });
// title = "Example"
//
// [server]
// port = 8080

try {
  parse('a = [1, 2');
} catch (e) {
  if (e instanceof TomlError) console.log(e.line, e.column, e.message);
}

Supported features

| Item | Details | | --- | --- | | Keys | key = value, dotted keys (a.b = 1), quoted keys | | Tables | [table], [[array of tables]] | | Strings | Basic, literal, and multi-line (basic / literal) | | Integers | Decimal, hexadecimal, octal, and binary, with _ separators. Values beyond the safe integer range become bigint; values beyond 64 bits are an error | | Floats | Exponent notation, inf / nan | | Other | Booleans, arrays (mixed types allowed), inline tables, # comments | | Date-times | Offset date-time, local date-time, local date, and local time. The format and value ranges are validated, and the value is returned as a string |

stringify

  • Supports strings, numbers (including inf / nan), bigint, booleans, Date (written as ISO 8601), arrays, and nested objects
  • A non-empty array whose elements are all objects is written as an [[array of tables]]
  • Properties set to undefined are omitted. null, functions, Map, and similar values are errors
  • Circular references are errors

Safety (DoS protection)

  • The input is scanned once from start to end, so parsing runs in time linear to the input size
  • Nesting depth is limited (100 by default). Depth is the number of tables and arrays (including arrays of tables) on the path from the root to a value. parse and stringify count depth the same way, so any value that parses can be stringified with the same limit. Recursion never exhausts the stack
  • Integers are checked against the range by digit count before being converted to BigInt, so extremely long numbers never trigger an expensive conversion
  • No regular expressions are used; characters are checked by character code
  • Keys such as __proto__ are set as own properties without modifying the prototype
parse(src, { maxDepth: 32 });
stringify(obj, { maxDepth: 32 });

Regression tests for large numbers of comment lines, deep nesting, long key lines, and malformed documents are in test/dos.test.ts.

Development

Requires Node.js 20 or later. (Running the tests from TypeScript source needs Node.js 22.18 or later.)

npm install
npm test           # Run tests (node:test runs .ts directly)
npm run typecheck  # Type-check
npm run build      # Emit JS and type definitions to dist/

License

MIT