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

next-build-parser

v1.3.0

Published

Parse the output of next build into machine readable JSON.

Readme

next-build-parser

🚀 A quick and easy tool to parse the output of the Next.js next build command into machine readable JSON, to fit whatever needs you may have.

Usage

💻 As a CLI

Assuming you have a build package.json script that runs next build, you can run:

npm run build > next-build.txt
npx next-build-parser next-build.txt

This will output a JSON object to stdout. If you would like to output it to a file, you can run:

npx next-build-parser next-build.txt --output output.json

For other CLI options, run:

npx next-build-parser --help

📦 In Code

First, install the package, and then run next build to generate the output file:

npm install next-build-parser
npm run build > next-build.txt

Then you can use it in your code:

import { parse } from 'next-build-parser';
import { readFileSync } from 'node:fs';

const file = readFileSync('next-build.txt', 'utf8');
const output = parse(file, {
  unit: 'MB',
});
console.log(output);

or using the more convenient parseFile function:

import { parseFile } from 'next-build-parser';

const output = parseFile('next-build.txt', {
  unit: 'MB',
});
console.log(output);

➡️ Output

The output is a JSON object with the following structure:

type Output = {
  routes: {
    name: string; // The name of the route, e.g. /blog
    type: string; // The type of the route, e.g. Dynamic, Static, etc.
    icon: string; // The icon of the route type, e.g. λ
    size: number; // The gzipped size of the route in the specified unit, e.g. 1000
    firstLoad: number; // The gzipped size of the first load JS in the specified unit, e.g. 1000
  }[];
  shared: {
    name: string; // The name of the chunk, e.g. chunks/472-9100b5fcfec8f88c.js
    size: number; // The gzipped size of the chunk in the specified unit, e.g. 1000
  }[];
  sharedTotal: number; // The total gzipped size of all the shared chunks in the specified unit, e.g. 1000
  unit: string; // The unit of the size, e.g. B, KB, MB, etc
  middleware?: number; // The gzipped size of the middleware in the specified unit, e.g. 1000
};

FAQs

  • What is the difference between firstLoad and size?

    size is the gzipped size of the route only, assuming the user has already downloaded the shared JS. This is representative of the download size for a user that has alreaedy visited another route, but is visiting this one for the first time.

    firstLoad is the total gzipped size of that route, which includes the shared JS. Other included files are typically shared layout files. This is representative of the download size for a user that is visiting this route for the first time, and has not visited any other route before this.

  • Why isn't firstLoad the sum of size and sharedTotal?

    This is usually because there is some other JS included in sharedTotal but not exclusive to this route, for example any client-side JS in Next.js layout files.