Nicholas Penree

Infinitely Curious

This is the personal weblog of Nicholas Penree.

node-keychain

Basic Keychain Access on Mac computers running Node.js

creatormaintained146470.0k/wkJanuary 2026

Tech Stack

JavaScriptNode.jsmacOS Security Framework

Features

  • Get, set, and delete passwords from Keychain
  • Support for generic and internet passwords
  • Create and manage custom keychains
  • Set default keychain programmatically

About node-keychain

This module provides basic Keychain access in Node.js by wrapping the macOS security command-line tool. It's a simple, reliable way to securely store and retrieve credentials in your Node.js applications on Mac.

Requirements

  • Mac OS X 10.6 or later
  • Node.js

API

1const keychain = require('keychain');
2
3// Set a password
4keychain.setPassword({
5 account: 'myapp',
6 service: 'MyService',
7 password: 'secret123'
8}, callback);
9
10// Get a password
11keychain.getPassword({
12 account: 'myapp',
13 service: 'MyService'
14}, callback);
15
16// Delete a password
17keychain.deletePassword({
18 account: 'myapp',
19 service: 'MyService'
20}, callback);

Features

  • Generic Passwords - Store application-specific credentials
  • Internet Passwords - Store web service credentials with server info
  • Keychain Management - Create, delete, and set default keychains
  • Async API - All operations use callbacks for non-blocking execution

Installation

1npm install keychain