
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
minimal-password-prompt
Advanced tools
Minimal hidden password prompt with no dependencies for Node.js.
Minimal hidden password prompt for Node.js! [npm] [github]

| package | dependencies | dependents | total lines of production code |
|---|---|---|---|
| minimal-password-prompt | 0 | 0 | 48 |
| password-prompt | 2 | 43 | 2147 |
Seriously, you can also just copy and paste to your project:
const stdin = process.stdin;
const stdout = process.stdout;
const captureStdin = (onData) => {
stdin.setEncoding('utf-8');
stdin.setRawMode(true);
stdin.on('data', onData);
stdin.resume();
};
const releaseStdin = (onData) => {
stdin.pause();
stdin.removeListener('data', onData);
stdin.setRawMode(false);
stdout.write('\n');
};
const prompt = (question, ctrlcExits = true) => (
new Promise((resolve, reject) => {
let input = '';
const onData = (data) => {
switch (data) {
case '\u000A': // \n
case '\u000D': // \r
case '\u0004': // Ctrl+D
releaseStdin(onData);
resolve(input);
break;
case '\u0003': // Ctrl+C
releaseStdin(onData);
ctrlcExits // exit or raise error
? process.exit()
: reject(new Error('Ctrl+C'));
break;
case '\u0008': // Backspace
case '\u007F': // Delete
input = input.slice(0, -1);
break;
default: // any other
input += data;
};
};
captureStdin(onData);
stdout.write(question);
})
);
module.exports = prompt;
(please sill do remember to include MIT license/copyright)
const prompt = require('minimal-password-prompt');
prompt('enter password: ').then(pw => {
console.log(`Password: ${pw}`);
});
or with async/await:
const prompt = require('minimal-password-prompt');
(async () => {
const pw = await prompt('enter password: ');
console.log(`password: ${pw}`);
})();
More examples here
Parameters:
question (String) prompt output before user inputctrlcExits (Boolean), optional
Returns:
Promise<String> user input during promptInstall with npm:
npm install --save minimal-password-prompt
FAQs
Minimal hidden password prompt with no dependencies for Node.js.
The npm package minimal-password-prompt receives a total of 510 weekly downloads. As such, minimal-password-prompt popularity was classified as not popular.
We found that minimal-password-prompt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.