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

@markusberg/lcov-parse

v3.0.0

Published

Parse lcov results files and return JSON

Readme

LCOV file parser

node.js build coverage version

Simple LCOV file parser to generate JSON and JSON-summary formatted reports.

Installation

$ npm install @markusberg/lcov-parse

Usage

Basic usage for loading and parsing an lcov.info file:

import { loadAndParse, type CoverageReport } from "@markusberg/lcov-parse"
const json: CoverageReport = await loadAndParse("./path/to/file.info")

Parsing already loaded data

If your lcov data is already loaded into a variable you can call the parsing function directly:

import { parse, type CoverageReport } from "@markusberg/lcov-parse"
const lcovData: string = "TN:TestName\nSF:foobar.js\nend_of_record\n"
const json: CoverageReport = parse(lcovData)

The json const will now contain this data:

[
  {
    "file": "foobar.js",
    "lines": { "found": 0, "hit": 0, "details": [] },
    "functions": { "hit": 0, "found": 0, "details": [] },
    "branches": { "hit": 0, "found": 0, "details": [] },
    "title": "TestName"
  }
]

JSON-summary

The JSON-summary format is convenient for CI purposes:

import {
  loadAndParse,
  generateSummary,
  type CoverageReport,
  type CoverageSummary,
} from "@markusberg/lcov-parse"

const json: CoverageReport = await loadAndParse("./path/to/file.info")
const summary: CoverageSummary = generateSummary(json)

The summary const will now contain the following data:

{
  "foobar.js": {
    "lines": { "total": 0, "covered": 0, "pct": 100 },
    "functions": { "total": 0, "covered": 0, "pct": 100 },
    "branches": { "total": 0, "covered": 0, "pct": 100 }
  },
  "total": {
    "lines": { "total": 0, "covered": 0, "pct": 100 },
    "functions": { "total": 0, "covered": 0, "pct": 100 },
    "branches": { "total": 0, "covered": 0, "pct": 100 }
  }
}

Formatting

The generated JSON will look like this:

 {
    "title": "Test #1",
    "file": "anim-base/anim-base-coverage.js",
    "functions": {
      "hit": 23,
      "found": 29,
      "details": [
        {
          "name": "(anonymous 1)",
          "line": 7,
          "hit": 6
        },
        {
          "name": "(anonymous 2)",
          "line": 620,
          "hit": 225
        },
        {
          "name": "_end",
          "line": 516,
          "hit": 228
        }
      ]
    }
    "lines": {
      "found": 181,
      "hit": 143,
      "details": [
        {
          "line": 7,
          "hit": 6
        },
        {
          "line": 29,
          "hit": 6
        }
      ]
    }
}

CLI Usage

In addition to the mandatory file name, the script takes two optional arguments:

  • --summary: generate a json-summary instead of a full json report
  • --pretty: indents and line breaks the json output

For example:

$ npx lcov-parse --summary --pretty ./coverage/lcov.info
{
  "src/index.ts": {
    "lines": {
      "total": 218,
      "covered": 218,
      "pct": 100
    },
    "functions": {
      "total": 8,
      "covered": 8,
      "pct": 100
    },
    "branches": {
      "total": 40,
      "covered": 40,
      "pct": 100
    }
  },
  "total": {
    "lines": {
      "total": 218,
      "covered": 218,
      "pct": 100
    },
    "functions": {
      "total": 8,
      "covered": 8,
      "pct": 100
    },
    "branches": {
      "total": 40,
      "covered": 40,
      "pct": 100
    }
  }
}

or

$ cat lcov.info | xargs -0 lcov-parse

Tests

$ npm install && npm test

or to run continuously, watching for changes:

$ npm run test:watch