enquirer, inquirer, and prompt-sync are all Node.js libraries designed to collect user input from the command line through interactive prompts. They enable developers to build rich terminal experiences by supporting various prompt types like text input, confirmation dialogs, multiple-choice selections, and more. While they share the same high-level goal, they differ significantly in architecture, feature set, performance characteristics, and use cases.
When building command-line tools in Node.js, you often need to ask users questions — whether it’s confirming a destructive action, selecting from options, or entering credentials. The three main libraries for this (enquirer, inquirer, and prompt-sync) solve the same problem but with very different trade-offs in design, performance, and capability. Let’s compare them head-to-head.
enquirer is built for speed and simplicity. It uses native Node.js readline under the hood and avoids heavy dependencies. All prompts are promise-based and non-blocking.
// enquirer: async/await with built-in prompt types
const { Select } = require('enquirer');
const prompt = new Select({
name: 'color',
message: 'Pick a color',
choices: ['red', 'blue', 'green']
});
const answer = await prompt.run();
console.log(answer); // e.g., 'blue'
inquirer offers a richer UI layer with extensive customization. It relies on external packages like chalk and rxjs, which increases bundle size but enables animated interfaces and complex interactions.
// inquirer: question object array with async flow
const inquirer = require('inquirer');
const answers = await inquirer.prompt([
{
type: 'list',
name: 'color',
message: 'Pick a color',
choices: ['red', 'blue', 'green']
}
]);
console.log(answers.color); // e.g., 'blue'
prompt-sync takes a radically different approach: it blocks execution until the user responds, using readlineSync internally. This makes it feel like window.prompt() in browsers.
// prompt-sync: synchronous, no async needed
const prompt = require('prompt-sync')();
const color = prompt('Pick a color (red/blue/green): ');
console.log(color); // e.g., 'blue'
💡 Key Insight:
prompt-sync’s sync model breaks Node.js’s event loop best practices and can cause issues in complex applications. Use it only for trivial scripts.
Not all libraries support the same kinds of questions.
enquirer: Has a dedicated Password prompt that hides input.const { Password } = require('enquirer');
const pass = await new Password({ message: 'Enter password' }).run();
inquirer: Supports type: 'password' in prompt objects.const answers = await inquirer.prompt([
{ type: 'password', name: 'pass', message: 'Enter password' }
]);
prompt-sync: No built-in masking. You’d have to implement hiding manually (which isn’t reliable cross-platform).// prompt-sync: no native password support
const pass = prompt('Password: '); // visible as typed
enquirer: Offers Select, MultiSelect, and Autocomplete out of the box.const { Autocomplete } = require('enquirer');
const choice = await new Autocomplete({
name: 'command',
message: 'Search command',
choices: ['build', 'test', 'deploy']
}).run();
inquirer: Supports list, checkbox, and third-party autocomplete plugins.await inquirer.prompt([
{ type: 'checkbox', name: 'tags', choices: ['a', 'b', 'c'] }
]);
prompt-sync: Only supports raw string input. You must parse and validate choices yourself.const input = prompt('Choose (a/b/c): ');
if (!['a','b','c'].includes(input)) throw new Error('Invalid');
Because enquirer avoids heavy dependencies, it loads faster than inquirer. In CLI tools where milliseconds matter (e.g., frequently run commands), this difference is noticeable.
prompt-sync has minimal overhead but blocks the thread — so while it “starts fast,” it freezes your program until input is given.
All three support input validation, but with different ergonomics.
enquirer lets you pass a validate function that returns true (valid) or an error message (invalid):
const { Input } = require('enquirer');
const email = await new Input({
message: 'Email?',
validate: value => /.+@.+/.test(value) || 'Invalid email'
}).run();
inquirer uses a similar pattern inside prompt objects:
await inquirer.prompt([
{
type: 'input',
name: 'email',
message: 'Email?',
validate: input => /.+@.+/.test(input) || 'Invalid email'
}
]);
prompt-sync has no built-in validation. You must loop manually:
let email;
do {
email = prompt('Email? ');
if (!/.+@.+/.test(email)) console.log('Invalid email');
} while (!/.+@.+/.test(email));
This quickly becomes tedious for anything beyond basic checks.
Some environments (like CI systems or Docker containers) don’t provide a real TTY, which can break interactive prompts.
enquirer: Gracefully degrades in non-TTY environments. You can supply default answers via environment variables or config.inquirer: May hang or throw errors in non-TTY contexts unless you explicitly disable interactivity.prompt-sync: Often fails in non-TTY environments because it tries to read from stdin synchronously without fallbacks.create-app generators)✅ Use enquirer — it’s fast, reliable, and handles edge cases well. Its API is clean and doesn’t bloat your dependency tree.
✅ Use inquirer — if you need animated spinners, custom renderers, or deep UI control, its ecosystem justifies the cost.
✅ Use prompt-sync — only when you want to avoid async complexity in throwaway code. Never in published packages.
| Feature | enquirer | inquirer | prompt-sync |
|---|---|---|---|
| Async/Await | ✅ Yes | ✅ Yes | ❌ No (sync only) |
| Password Masking | ✅ Built-in | ✅ Built-in | ❌ Not supported |
| Multiple Choice | ✅ Select/MultiSelect | ✅ list/checkbox | ❌ Manual parsing |
| Autocomplete | ✅ Native | ✅ Via plugins | ❌ No |
| Validation | ✅ Function-based | ✅ Function-based | ❌ Manual loop required |
| Non-TTY Safe | ✅ Yes | ⚠️ Needs config | ❌ Often fails |
| Dependencies | 🟢 Minimal | 🔴 Heavy (chalk, rxjs…) | 🟢 Very light |
| Startup Speed | ⚡ Fast | 🐢 Slower | ⚡ Fast (but blocks) |
Don’t pick based on popularity alone. Ask:
prompt-sync.prompt-sync.enquirer over inquirer.prompt-sync entirely.In 2024, enquirer is the best default choice for most new CLI projects. inquirer remains viable for legacy or highly customized interfaces. prompt-sync should be reserved for quick demos or internal scripts where simplicity trumps robustness.
Choose inquirer if you’re working on an interactive CLI application that requires highly customizable UI components and you don’t mind slightly slower startup due to its larger dependency footprint. Its plugin ecosystem and mature API make it well-suited for complex workflows like scaffolding tools or configuration wizards.
Choose enquirer if you need a fast, modern, and actively maintained library with built-in support for advanced prompt types (like autocomplete, multiselect, and password masking) and minimal dependencies. It’s ideal for CLI tools where startup speed and reliability matter, especially in environments that may not support TTY features fully.
Choose prompt-sync if you need synchronous, blocking input without callbacks or async/await — useful for simple scripts, educational examples, or environments where asynchronous I/O complicates control flow. However, avoid it in production CLIs that require responsive interfaces or advanced prompt types, as it lacks features like selection lists or validation.
A collection of common interactive command line user interfaces.
[!IMPORTANT] This is the legacy version of Inquirer.js. While it still receives maintenance, it is not actively developed. For the new Inquirer, see @inquirer/prompts.
Inquirer.js strives to be an easily embeddable and beautiful command line interface for Node.js (and perhaps the "CLI Xanadu").
Inquirer.js should ease the process of
Note:
Inquirer.jsprovides the user interface and the inquiry session flow. If you're searching for a full blown command line program utility, then check out commander, vorpal or args.
| npm | yarn |
|---|---|
|
|
import inquirer from 'inquirer';
inquirer
.prompt([
/* Pass your questions in here */
])
.then((answers) => {
// Use user feedback for... whatever!!
})
.catch((error) => {
if (error.isTtyError) {
// Prompt couldn't be rendered in the current environment
} else {
// Something else went wrong
}
});
Check out the packages/inquirer/examples/ folder for code and interface examples.
yarn node packages/inquirer/examples/pizza.js
yarn node packages/inquirer/examples/checkbox.js
# etc...
[!WARNING] Those interfaces are not necessary for modern Javascript, while still maintained, they're depreciated. We highly encourage you to adopt the more ergonomic and modern API with @inquirer/prompts. Both
inquirerand@inquirer/promptsare usable at the same time, so you can progressively migrate.
inquirer.prompt(questions, answers) -> promiseLaunch the prompt interface (inquiry session)
Rx.Observable instance){}.inquirer.registerPrompt(name, prompt)Register prompt plugins under name.
type)inquirer.createPromptModule() -> prompt functionCreate a self contained inquirer module. If you don't want to affect other libraries that also rely on inquirer when you overwrite or add new prompt types.
const prompt = inquirer.createPromptModule();
prompt(questions).then(/* ... */);
A question object is a hash containing question related values:
input - Possible values: input, number, confirm, list, rawlist, expand, checkbox, password, editorname (followed by a colon).numbers, strings, or objects containing a name (to display in list), a value (to save in the answers hash), and a short (to display after selection) properties. The choices array can also contain a Separator.true if the value is valid, and an error message (String) otherwise. If false is returned, a default error message is provided.true or false depending on whether or not this question should be asked. The value can also be a simple boolean.list, rawList, expand or checkbox.truetruedefault, choices(if defined as functions), validate, filter and when functions can be called asynchronously. Either return a promise or use this.async() to get a callback you'll call with the final value.
{
/* Preferred way: with promise */
filter() {
return new Promise(/* etc... */);
},
/* Legacy way: with this.async */
validate: function (input) {
// Declare function as asynchronous, and save the done callback
const done = this.async();
// Do async stuff
setTimeout(function() {
if (typeof input !== 'number') {
// Pass the return value in the done callback
done('You need to provide a number');
} else {
// Pass the return value in the done callback
done(null, true);
}
}, 3000);
}
}
A key/value hash containing the client answers in each prompt.
name property of the question objectconfirm: (Boolean)input : User input (filtered if filter is defined) (String)number: User input (filtered if filter is defined) (Number)rawlist, list : Selected choice value (or name if no value specified) (String)
A separator can be added to any choices array:
// In the question object
choices: [ "Choice A", new inquirer.Separator(), "choice B" ]
// Which'll be displayed this way
[?] What do you want to do?
> Order a pizza
Make a reservation
--------
Ask opening hours
Talk to the receptionist
The constructor takes a facultative String value that'll be use as the separator. If omitted, the separator will be --------.
Separator instances have a property type equal to separator. This should allow tools façading Inquirer interface from detecting separator types in lists.
Note:: allowed options written inside square brackets (
[]) are optional. Others are required.
{type: 'list'}Take type, name, message, choices[, default, filter, loop] properties.
(Note: default must be set to the index or value of one of the entries in choices)
{type: 'rawlist'}Take type, name, message, choices[, default, filter, loop] properties.
(Note: default must be set to the index of one of the entries in choices)
{type: 'expand'}Take type, name, message, choices[, default] properties.
Note: default must be the index of the desired default selection of the array. If default key not provided, then help will be used as default choice
Note that the choices object will take an extra parameter called key for the expand prompt. This parameter must be a single (lowercased) character. The h option is added by the prompt and shouldn't be defined by the user.
See examples/expand.js for a running example.
{type: 'checkbox'}Take type, name, message, choices[, filter, validate, default, loop] properties. default is expected to be an Array of the checked choices value.
Choices marked as {checked: true} will be checked by default.
Choices whose property disabled is truthy will be unselectable. If disabled is a string, then the string will be outputted next to the disabled choice, otherwise it'll default to "Disabled". The disabled property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.
{type: 'confirm'}Take type, name, message, [default, transformer] properties. default is expected to be a boolean if used.
{type: 'input'}Take type, name, message[, default, filter, validate, transformer] properties.
{type: 'number'}Take type, name, message[, default, filter, validate, transformer] properties.
{type: 'password'}Take type, name, message, mask,[, default, filter, validate] properties.
Note that mask is required to hide the actual user input.
{type: 'editor'}Take type, name, message[, default, filter, validate, postfix, waitUserInput] properties
Launches an instance of the users preferred editor on a temporary file. Once the user exits their editor, the contents of the temporary file are read in as the result. The editor to use is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, notepad (on Windows) or vim (Linux or Mac) is used.
The postfix property is useful if you want to provide an extension.
prompt() requires that it is run in an interactive environment. (I.e. One where process.stdin.isTTY is true). If prompt() is invoked outside of such an environment, then prompt() will return a rejected promise with an error. For convenience, the error will have a isTtyError property to programmatically indicate the cause.
Internally, Inquirer uses the JS reactive extension to handle events and async flows.
This mean you can take advantage of this feature to provide more advanced flows. For example, you can dynamically add questions to be asked:
const prompts = new Rx.Subject();
inquirer.prompt(prompts);
// At some point in the future, push new questions
prompts.next({
/* question... */
});
prompts.next({
/* question... */
});
// When you're done
prompts.complete();
And using the return value process property, you can access more fine grained callbacks:
inquirer.prompt(prompts).ui.process.subscribe(onEachAnswer, onError, onComplete);
You should expect mostly good support for the CLI below. This does not mean we won't look at issues found on other command line - feel free to report any!
nodemon - Makes the arrow keys print gibrish on list prompts.
Workaround: Add { stdin : false } in the configuration file or pass --no-stdin in the CLI.
Please refer to this issue
grunt-exec - Calling a node script that uses Inquirer from grunt-exec can cause the program to crash. To fix this, add to your grunt-exec config stdio: 'inherit'.
Please refer to this issue
Windows network streams - Running Inquirer together with network streams in Windows platform inside some terminals can result in process hang. Workaround: run inside another terminal. Please refer to this issue
Please refer to the GitHub releases section for the changelog
Unit test
Please add a unit test for every new feature or bug fix. yarn test to run the test suite.
Documentation Add documentation for every API change. Feel free to send typo fixes and better docs!
We're looking to offer good support for multiple prompts and environments. If you want to help, we'd like to keep a list of testers for each terminal/OS so we can contact you and get feedback before release. Let us know if you want to be added to the list (just tweet to @vaxilart) or just add your name to the wiki
Copyright (c) 2023 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.
You can build custom prompts, or use open sourced ones. See @inquirer/core documentation for building custom prompts.
You can either call the custom prompts directly (preferred), or you can register them (depreciated):
import customPrompt from '$$$/custom-prompt';
// 1. Preferred solution with new plugins
const answer = await customPrompt({ ...config });
// 2. Depreciated interface (or for old plugins)
inquirer.registerPrompt('custom', customPrompt);
const answers = await inquirer.prompt([
{
type: 'custom',
...config,
},
]);
When using Typescript and registerPrompt, you'll also need to define your prompt signature. Since Typescript is static, we cannot infer available plugins from function calls.
import customPrompt from '$$$/custom-prompt';
declare module 'inquirer' {
interface QuestionMap {
// 1. Easiest option
custom: Parameters<typeof customPrompt>[0];
// 2. Or manually define the prompt config
custom_alt: { message: string; option: number[] };
}
}
autocomplete
Presents a list of options as the user types, compatible with other packages such as fuzzy (for search)

checkbox-plus
Checkbox list with autocomplete and other additions

inquirer-date-prompt
Customizable date/time selector with localization support

datetime
Customizable date/time selector using both number pad and arrow keys

inquirer-select-line
Prompt for selecting index in array where add new element

command
Simple prompt with command history and dynamic autocomplete
inquirer-fuzzy-path
Prompt for fuzzy file/directory selection.

inquirer-emoji
Prompt for inputting emojis.

inquirer-chalk-pipe
Prompt for input chalk-pipe style strings

inquirer-search-checkbox
Searchable Inquirer checkbox

inquirer-search-list
Searchable Inquirer list

inquirer-prompt-suggest
Inquirer prompt for your less creative users.

inquirer-s3
An S3 object selector for Inquirer.

inquirer-autosubmit-prompt
Auto submit based on your current input, saving one extra enter
inquirer-file-tree-selection-prompt
Inquirer prompt for to select a file or directory in file tree

inquirer-tree-prompt
Inquirer prompt to select from a tree

inquirer-table-prompt
A table-like prompt for Inquirer.

inquirer-table-input
A table editing prompt for Inquirer.

inquirer-interrupted-prompt
Turning any existing inquirer and its plugin prompts into prompts that can be interrupted with a custom key.

inquirer-press-to-continue
A "press any key to continue" prompt for Inquirer.js
