Registry / devops / next-build-parser

next-build-parser

JSON →
library1.3.0jsnpmunverified

next-build-parser is a utility designed to parse the console output of the Next.js `next build` command into a structured, machine-readable JSON format. This allows developers and automated systems to programmatically analyze build artifacts, route sizes, and performance metrics without relying on manual parsing of text output. The package is currently at version 1.3.0, indicating a stable and actively maintained state. It provides both a command-line interface (CLI) for direct use in scripts and a programmatic API for integration into JavaScript/TypeScript applications. Its key differentiator is the ability to break down route-specific `size` versus `firstLoad` metrics, alongside shared chunk information, making it valuable for performance monitoring and build optimization workflows. While no specific release cadence is announced, it appears to be actively developed in response to Next.js updates.

npm install next-build-parser
INSTALL
IMPORT
SIG · NEXT-BUILD-PARSER
N
next-build-parser
devopsjavascriptv1.3.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
✓ import { parse } from 'next-build-parser';
✗ const { parse } = require('next-build-parser');
The library is primarily designed for ESM consumption, though CommonJS usage is often attempted incorrectly.
parseFile
✓ import { parseFile } from 'next-build-parser';
✗ const parseFile = require('next-build-parser').parseFile;
A convenient function for reading directly from a file path, abstracting `readFileSync`.
Output
✓ import type { Output } from 'next-build-parser';
Type import for the structured JSON output, useful for TypeScript projects.

This quickstart demonstrates how to run `next build`, capture its output to a file, and then programmatically parse that file into a structured JSON object using `parseFile` for analysis.

import { parseFile } from 'next-build-parser'; import { writeFileSync, existsSync, mkdirSync } from 'node:fs'; import { execSync } from 'node:child_process'; import { join } from 'node:path'; const tempDir = join(process.cwd(), 'temp-next-build-output'); if (!existsSync(tempDir)) { mkdirSync(tempDir); } const outputFile = join(tempDir, 'next-build.txt'); console.log('Running `next build` and redirecting output...'); try { execSync('npm run build > ' + outputFile, { stdio: 'pipe' }); console.log(`Build output saved to ${outputFile}`); } catch (error) { console.error('Failed to run next build. Ensure you have a Next.js project and `npm run build` works.'); console.error(error.message); process.exit(1); } async function main() { console.log('Parsing next build output...'); try { const output = await parseFile(outputFile, { unit: 'KB', }); console.log('Parsed output:'); console.log(JSON.stringify(output, null, 2)); writeFileSync(join(tempDir, 'parsed-output.json'), JSON.stringify(output, null, 2)); console.log(` Full parsed JSON saved to ${join(tempDir, 'parsed-output.json')}`); } catch (error) { console.error('Error parsing build file:', error.message); } } main();
next-build-parser --version
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
13
OpenAI (training)
2
Anthropic
1
Resources
next-build-parser — npm install next-build-parser · libregistry