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

@ameyanagi/chemical-formula

v0.1.3

Published

Chemical formula parser with catalyst loading notation support

Downloads

40

Readme

@ameyanagi/chemical-formula

WASM/Node.js bindings for the Rust chemical-formula parser.

Use this package to parse chemical formulas, convert between molecular and weight-percent representations, and calculate molecular weights. It supports ordinary formulas such as H2O, weight-percent annotations such as Pt5wt%/SiO2, and flexible catalyst loading notation such as 1%Pt/SiO2, Pt1%/SiO2, and 1wt%Pt@SiO2.

Installation

npm install @ameyanagi/chemical-formula

With Bun:

bun add @ameyanagi/chemical-formula

Quick Start

import {
  molecularWeight,
  parseFormula,
  toMolecularFormula,
  toWtPercent,
} from "@ameyanagi/chemical-formula";

const catalyst = parseFormula("1%Pt/SiO2");

console.log(catalyst);
// {
//   formula: "Pt1wt%O2Si",
//   elements: ["O", "Si", "Pt"],
//   stoichiometry: { O: 2, Si: 1 },
//   wt_percent: { Pt: 1 }
// }

const molecular = toMolecularFormula("1%Pt/SiO2");
console.log(molecular.stoichiometry.Pt);
// 0.0031109624054201776

const water = toWtPercent("H2O");
console.log(water.wt_percent);
// { H: 11.19067443796836, O: 88.80932556203165 }

console.log(molecularWeight("H2O"));
// 18.015

API

type FormulaSummary = {
  formula: string;
  elements: string[];
  stoichiometry: Record<string, number>;
  wt_percent: Record<string, number>;
};
  • parseFormula(input: string): FormulaSummary
  • toMolecularFormula(input: string): FormulaSummary
  • toWtPercent(input: string): FormulaSummary
  • molecularWeight(input: string): number

All parsing and conversion errors are thrown as JavaScript errors.

Supported Notation Examples

These examples all describe 1 wt% Pt on silica:

parseFormula("1%Pt/SiO2");
parseFormula("Pt1%/SiO2");
parseFormula("1wt%Pt/SiO2");
parseFormula("Pt1wt%/SiO2");
parseFormula("1wt%Pt@SiO2");
parseFormula("1 wt % Pt / SiO2");

Bare % is interpreted as wt%.

Nested materials are supported:

const composite = toWtPercent("(Pt5wt%/SiO2)50wt%(CeO2)50wt%");

console.log(composite.wt_percent.Pt);
// 2.5000000000000004

Package Notes

This package is generated from the Rust crate with wasm-pack and targets Node.js-compatible runtimes.