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

@padmaj/logfmt

v1.0.1

Published

Serialize objects to logfmt key=value format. Works with Datadog, Grafana, and Heroku logs.

Readme

@padmaj/logfmt

Serialize objects to logfmt key=value format and parse them back. Zero dependencies. TypeScript-first. Works in Node and browser.

Compatible with Datadog, Grafana, Heroku, and any log aggregator that speaks logfmt.

Install

npm install @padmaj/logfmt

Usage

Serialize → logfmt string

import { logfmt } from '@padmaj/logfmt'

logfmt({ level: 'info', msg: 'server started', port: 3000 })
// → 'level=info msg="server started" port=3000'

logfmt({ level: 'error', ok: false, latency: 1.5 })
// → 'level=error ok=false latency=1.5'

Parse logfmt string → object

import { parseLogfmt } from '@padmaj/logfmt'

parseLogfmt('level=info msg="server started" port=3000')
// → { level: 'info', msg: 'server started', port: '3000' }

Use with console.log

console.log(logfmt({ level: 'info', msg: 'request received', path: '/api/users', ms: 42 }))
// level=info msg="request received" path=/api/users ms=42

Serialization rules

| Value type | Example input | Output | |---|---|---| | Plain string | 'info' | level=info | | String with spaces | 'server started' | msg="server started" | | String with = | 'a=b' | expr="a=b" | | Number | 3000 | port=3000 | | Boolean | true | ok=true | | null | null | err (bare key) | | undefined | undefined | (omitted) |

API

logfmt(obj: Record<string, string | number | boolean | null | undefined>): string

Serializes an object to a logfmt string.

parseLogfmt(line: string): Record<string, string>

Parses a logfmt string back into an object. All values are returned as strings.

Notes

  • logfmt and parseLogfmt are round-trip compatible — parsing a serialized string returns the original values (as strings).
  • Keys with undefined values are omitted from output.
  • Keys with null values are rendered as bare keys (no =value).
  • Keys must not contain spaces, =, or "logfmt throws if they do.
  • parseLogfmt rejects inputs longer than 10,000 characters with a RangeError.

License

MIT