{"id":13602,"library":"next-build-parser","title":"Next.js Build Output Parser","description":"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.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/blairmcalpine/next-build-parser","tags":["javascript","nextjs","next.js","next","build","parse","typescript"],"install":[{"cmd":"npm install next-build-parser","lang":"bash","label":"npm"},{"cmd":"yarn add next-build-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add next-build-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library is primarily designed for ESM consumption, though CommonJS usage is often attempted incorrectly.","wrong":"const { parse } = require('next-build-parser');","symbol":"parse","correct":"import { parse } from 'next-build-parser';"},{"note":"A convenient function for reading directly from a file path, abstracting `readFileSync`.","wrong":"const parseFile = require('next-build-parser').parseFile;","symbol":"parseFile","correct":"import { parseFile } from 'next-build-parser';"},{"note":"Type import for the structured JSON output, useful for TypeScript projects.","symbol":"Output","correct":"import type { Output } from 'next-build-parser';"}],"quickstart":{"code":"import { parseFile } from 'next-build-parser';\nimport { writeFileSync, existsSync, mkdirSync } from 'node:fs';\nimport { execSync } from 'node:child_process';\nimport { join } from 'node:path';\n\nconst tempDir = join(process.cwd(), 'temp-next-build-output');\nif (!existsSync(tempDir)) {\n  mkdirSync(tempDir);\n}\nconst outputFile = join(tempDir, 'next-build.txt');\n\nconsole.log('Running `next build` and redirecting output...');\ntry {\n  execSync('npm run build > ' + outputFile, { stdio: 'pipe' });\n  console.log(`Build output saved to ${outputFile}`);\n} catch (error) {\n  console.error('Failed to run next build. Ensure you have a Next.js project and `npm run build` works.');\n  console.error(error.message);\n  process.exit(1);\n}\n\nasync function main() {\n  console.log('Parsing next build output...');\n  try {\n    const output = await parseFile(outputFile, {\n      unit: 'KB',\n    });\n    console.log('Parsed output:');\n    console.log(JSON.stringify(output, null, 2));\n    writeFileSync(join(tempDir, 'parsed-output.json'), JSON.stringify(output, null, 2));\n    console.log(`\nFull parsed JSON saved to ${join(tempDir, 'parsed-output.json')}`);\n  } catch (error) {\n    console.error('Error parsing build file:', error.message);\n  }\n}\n\nmain();\n","lang":"typescript","description":"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."},"warnings":[],"env_vars":null,"search_vec":"'1.3.0':62 'abil':98 'activ':67,134 'allow':33 'alongsid':109 'analyz':40 'announc':129 'api':87 'appear':131 'applic':92 'artifact':42 'autom':36 'break':100 'build':2,7,22,41,120,145 'cadenc':127 'chunk':111 'cli':78 'command':23,75 'command-lin':74 'consol':16 'current':59 'design':12 'develop':34,135 'differenti':95 'direct':80 'firstload':107 'format':31 'indic':63 'inform':112 'integr':89 'interfac':77 'javascript':141 'javascript/typescript':91 'json':30 'key':94 'line':76 'machin':28 'machine-read':27 'maintain':68 'make':113 'manual':51 'metric':47,108 'monitor':118 'next':6,21,144 'next-build-pars':5 'next.js':1,20,139,143 'nextj':142 'optim':121 'output':3,17,55 'packag':57 'pars':14,52,146 'parser':4,8 'perform':46,117 'programmat':39,86 'provid':71 'readabl':29 'releas':126 'reli':49 'respons':137 'rout':43,103 'route-specif':102 'script':83 'share':110 'size':44,105 'specif':104,125 'stabl':65 'state':69 'structur':26 'system':37 'text':54 'typescript':147 'updat':140 'use':81 'util':11 'valuabl':115 'version':61 'versus':106 'without':48 'workflow':122","created_at":"2026-04-20T01:55:20.895895+00:00","updated_at":"2026-04-20T01:55:20.895895+00:00","problems":[],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"next-build-parser","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/blairmcalpine/next-build-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/next-build-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}