inquirer

Interactive CLI user interfaces for Node.js — prompt users for input, choices, confirmations, and passwords in terminal tools.

inquirer

General JS

Interactive CLI user interfaces for Node.js — prompt users for input, choices, confirmations, and passwords in terminal tools.

Fit

Bundle (gzip)

198.7 kB

383.2 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

Building interactive CLI wizards — project generators, configuration tools, deployment scripts — requires collecting user input via prompts with validation, default values, and conditional logic. Parsing raw readline input is verbose.

What It Does

Inquirer provides a promise-based API for asking questions: text input, password masking, checkboxes, lists, confirmations, and editors. Answers can be validated in real time, and conditional prompts show/hide based on previous answers.

Installation

bash
npm install inquirer
npm install -D @types/inquirer

Usage Example

typescript
import inquirer from 'inquirer';

const answers = await inquirer.prompt([
  {
    type: 'input',
    name: 'projectName',
    message: 'Project name:',
    validate: (input) => /^[a-z-]+$/.test(input) || 'Use lowercase letters and hyphens only',
  },
  {
    type: 'list',
    name: 'framework',
    message: 'Choose a framework:',
    choices: ['Next.js', 'Remix', 'Astro', 'SvelteKit'],
  },
  {
    type: 'confirm',
    name: 'typescript',
    message: 'Use TypeScript?',
    default: true,
  },
]);

console.log(`Creating ${answers.framework} project: ${answers.projectName}`);

Related packages