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

css-font-shorthand-kit

v0.1.0

Published

Parse and format CSS font shorthand values with structured diagnostics.

Readme

css-font-shorthand-kit

License: MPL-2.0 CI

Small TypeScript library for parsing CSS font shorthand values into a predictable object, with structured diagnostics when a value is incomplete or ambiguous.

Package quality

  • TypeScript types are generated from the source.
  • ESM-only package marked as side-effect free for bundlers.
  • CI runs npm ci, typecheck, build, and test.
  • Tested on Node.js 20 and 22 with GitHub Actions.

Demo

Try the interactive demo

import { parseFontShorthand } from "css-font-shorthand-kit";

const font = parseFontShorthand('italic 700 1rem/1.4 "Inter", system-ui');

font.value;
// {
//   style: "italic",
//   weight: "700",
//   size: "1rem",
//   lineHeight: "1.4",
//   family: ["Inter", "system-ui"]
// }

Install

npm install css-font-shorthand-kit

API

parseFontShorthand(input, options?)

Returns a discriminated result instead of throwing:

type ParseFontResult =
  | { ok: true; value: ParsedFontShorthand; warnings: FontDiagnostic[] }
  | { ok: false; errors: FontDiagnostic[]; warnings: FontDiagnostic[] };

tryParseFontShorthand(input, options?)

Returns the parsed value or null.

parseFontFamilyList(input)

Parses a comma-separated font-family list, preserving quoted family names without the surrounding quotes.

formatFontShorthand(value)

Serializes a parsed value back to a compact CSS font shorthand string.

Supported scope

  • CSS system font keywords such as menu and caption
  • common font-style, font-variant, font-weight, and font-stretch tokens
  • font-size with optional /line-height
  • comma-separated font families, including quoted names and escaped quotes
  • diagnostics for missing size/family, duplicate tokens, unknown pre-size tokens, and unterminated quotes

This package intentionally does not attempt to be a full CSS parser. It is meant for tools that need a small, browser-friendly parser for one property.

Browser compatibility

The core uses only strings, arrays, and regular expressions. It has no runtime dependency and no Node-only API requirement.

CLI

No CLI is included. The natural use is as an embeddable helper inside CSS, canvas, design-token, editor, and browser tooling.

License

MPL-2.0