consolelog.tools

Package.json Scripts Generator

Generate npm scripts for different project types and package managers — dev, build, test, lint, and more

About this ToolHow it works, benefits & use cases

Stop copying the same dev/build/test scripts between projects — this generator builds a ready-to-paste "scripts" block tailored to your stack. Pick a project type (Next.js, React with Vite, Vue, Node.js, TypeScript, an NPM library, or full-stack) and it produces the right baseline commands: next dev/build/start and type-check for Next.js, vite and vitest for React, tsup for libraries, nodemon and ts-node-dev for Node and TypeScript, and concurrent client/server scripts for full-stack. Toggle on testing (jest/vitest/playwright plus ci variants), linting (eslint plus lint-staged), formatting (prettier), and Docker scripts, and adding linting or testing automatically wires in quality scripts like prepare, validate, and pre-commit hooks. Switch the package manager to Yarn or pnpm and the script bodies are rewritten accordingly. The output is live JSON you copy straight into package.json — no install, no sign-up.

How to Use

  1. 1Pick a project type from the dropdown — Next.js, React (Vite), Vue, Node.js, TypeScript, NPM Library, or Full-stack.
  2. 2Choose your package manager (npm, Yarn, or pnpm) so script bodies use the right run syntax.
  3. 3Toggle the "Additional scripts" checkboxes for Testing, Linting, Formatting, and Docker as needed.
  4. 4Or click a quick-template chip (Basic Node, TypeScript, React App, Next.js App, NPM Library) for a preset.
  5. 5The "scripts" JSON updates live — copy or download it and paste it into your package.json.

Key Benefits

  • Stack-aware presets for Next.js, React/Vite, Vue, Node, TypeScript, libraries, and full-stack
  • Optional testing, linting, formatting, and Docker script groups via checkboxes
  • Auto-adds quality scripts (prepare, validate, pre-commit, check-all) when linting or testing is on
  • Rewrites internal npm run references to Yarn or pnpm when you switch managers
  • Live JSON output that drops straight into the "scripts" field of package.json
  • Quick-template chips for instant common setups
  • Includes test:ci, test:e2e (Playwright), lint:fix, and format:check variants

Common Use Cases

  • Bootstrapping the scripts block for a brand-new Next.js or Vite project
  • Adding a consistent lint/format/test workflow to an existing repo
  • Setting up publish-ready scripts (tsup build, prepublishOnly) for an npm library
  • Generating CI-friendly scripts like test:ci and validate for a pipeline
  • Standardising script names across team projects regardless of package manager

Quick templates

Configuration

Additional scripts

Updates live — copy this "scripts" block into your package.json

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "eslint .",
    "type-check": "tsc --noEmit",
    "build:analyze": "ANALYZE=true next build",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage",
    "test:ci": "jest --ci --coverage --maxWorkers=2",
    "test:e2e": "playwright test",
    "test:e2e:ui": "playwright test --ui",
    "lint:fix": "eslint . --fix",
    "lint:staged": "lint-staged",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
    "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
    "prepare": "husky install",
    "pre-commit": "lint-staged",
    "pre-push": "npm run type-check && npm run test",
    "validate": "npm run lint && npm run type-check && npm run test",
    "check-all": "npm run format:check && npm run lint && npm run type-check && npm run test"
  }
}

Common scripts reference

Development

  • dev — start development server
  • build — build for production
  • start — start production server
  • preview — preview production build

Quality

  • test — run tests
  • lint — check code quality
  • format — format code
  • type-check — check TypeScript types

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools