
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@varlock/keepass-plugin
Advanced tools
Varlock plugin to load secrets from KeePass databases (KDBX 4.0) and KeePassXC desktop app
This package is a Varlock plugin that enables loading secrets from KeePass / KeePassXC databases (KDBX 4.0) into your configuration.
keepassxc-cli for development workflows#attribute syntaxkpBulk() via @setValuesBulk to load all entries in a groupcustomAttributesObj=trueIf you are in a JavaScript based project and have a package.json file, you can either install the plugin explicitly:
npm install @varlock/keepass-plugin
And then register the plugin without any version number:
# @plugin(@varlock/keepass-plugin)
# ---
Otherwise just set the explicit version number when you register it:
# @plugin(@varlock/keepass-plugin@0.0.1)
# ---
See our Plugin Guide for more details.
In file mode, the plugin opens and reads .kdbx files directly using kdbxweb. No external CLI is needed.
# @plugin(@varlock/keepass-plugin)
# @initKeePass(dbPath="./secrets.kdbx", password=$KP_PASSWORD)
# ---
When useCli=true, the plugin uses keepassxc-cli to read entries. This is useful during development when you want to leverage KeePassXC's system integration (e.g., YubiKey, Windows Hello). The useCli option can be dynamic — for example, useCli=forEnv(dev) to only use the CLI in development.
# @plugin(@varlock/keepass-plugin)
# @initKeePass(dbPath="./secrets.kdbx", password=$KP_PASSWORD, useCli=true)
# ---
You must have KeePassXC installed, which includes keepassxc-cli:
# macOS
brew install --cask keepassxc
# Ubuntu/Debian
sudo apt install keepassxc
# Fedora/RHEL
sudo dnf install keepassxc
# Arch
pacman -S keepassxc
See KeePassXC downloads for more options.
After registering the plugin, initialize it with the @initKeePass root decorator.
# @plugin(@varlock/keepass-plugin)
# @initKeePass(dbPath="./secrets.kdbx", password=$KP_PASSWORD)
# ---
# @type=kdbxPassword @sensitive @internal
KP_PASSWORD=
# @plugin(@varlock/keepass-plugin)
# @initKeePass(dbPath="./secrets.kdbx", password=$KP_PASSWORD, keyFile="./secrets.keyx")
# ---
# @plugin(@varlock/keepass-plugin)
# @initKeePass(id=prod, dbPath="./prod.kdbx", password=$KP_PROD_PASSWORD)
# @initKeePass(id=dev, dbPath="./dev.kdbx", password=$KP_DEV_PASSWORD)
# ---
PROD_DB_PASS=kp(prod, "Database/production")
DEV_DB_PASS=kp(dev, "Database/development")
Once initialized, use the kp() resolver to fetch secrets.
# Fetch password (default attribute) from an entry
DB_PASSWORD=kp("Database/production")
# Fetch a different attribute using #attribute syntax
DB_USER=kp("Database/production#UserName")
DB_URL=kp("Database/production#URL")
# Read a custom string field
API_KEY=kp("Services/stripe#SecretKey")
When the env var key matches a KeePass entry title, you can omit the entry path:
# Looks up entry titled "DB_PASSWORD", reads the Password field
DB_PASSWORD=kp()
# Looks up entry titled "DB_USER", reads the UserName field
DB_USER=kp("#UserName")
You can also use the attribute named param as an alternative to #attribute:
DB_USER=kp("Database/production", attribute=UserName)
Entry paths use forward slashes to separate groups from the entry title:
Group/SubGroup/EntryTitle
For example, if your KeePass database has:
You would reference them as "Database/production" and "Services/stripe".
Use customAttributesObj=true to load all custom (non-standard) fields from a single entry as a JSON object. This is useful with @setValuesBulk to expand custom fields into env vars:
# Given an entry "Database/production" with custom fields: HOST, PORT, DB_NAME
# @setValuesBulk(kp("Database/production", customAttributesObj=true), createMissing=true)
# ---
HOST=
PORT=
DB_NAME=
Standard fields (Title, Password, UserName, URL, Notes) are excluded — only custom fields are included.
Use kpBulk() with @setValuesBulk to fetch the Password field from all entries under a group:
# @plugin(@varlock/keepass-plugin)
# @initKeePass(dbPath="./secrets.kdbx", password=$KP_PASSWORD)
# @setValuesBulk(kpBulk(Production), createMissing=true)
# ---
# These will be populated from entries under the "Production" group
DB_PASSWORD=
API_KEY=
# Load all entries from the database root
# @setValuesBulk(kpBulk())
# Load from a specific group
# @setValuesBulk(kpBulk("Services/APIs"))
# With a named instance
# @setValuesBulk(kpBulk(prod, Production))
Entry paths in the JSON output are sanitized to valid env var names (uppercased, non-alphanumeric characters replaced with underscores).
@initKeePass()Initialize a KeePass plugin instance.
| Parameter | Type | Required | Description |
|---|---|---|---|
dbPath | string | yes | Path to the .kdbx database file |
password | string | yes | Master password (typically from an env var like $KP_PASSWORD) |
keyFile | string | no | Path to a key file for additional authentication |
useCli | boolean | no | Use keepassxc-cli instead of reading the file directly (default: false). Can be dynamic, e.g. useCli=forEnv(dev) |
id | string | no | Instance identifier for multiple databases (defaults to _default) |
kdbxPasswordA sensitive string type for KeePass database master passwords. Validates that the value is a non-empty string.
kp()Fetch a single entry field from a KeePass database.
Signatures:
kp() — infer entry name from key, read Password fieldkp(entryPath) — read Password fieldkp("entryPath#Attribute") — read a specific attributekp("#Attribute") — infer entry name from key, read a specific attributekp(entryPath, attribute=X) — read a specific attribute (named param)kp(instanceId, entryPath) — read from a named database instancekp(entryPath, customAttributesObj=true) — return all custom fields as a JSON objectReturns: The field value as a string, or a JSON object string when customAttributesObj=true.
kpBulk()Fetch the Password field from all entries under a group as a JSON map. Intended for use with @setValuesBulk.
Signatures:
kpBulk() — load all entries from the database rootkpBulk(groupPath) — load entries under a specific groupkpBulk(instanceId, groupPath) — load from a named instanceReturns: JSON string of { "ENTRY_NAME": "password", ... } pairs. Entry paths are sanitized to valid env var names.
"Group/SubGroup/Entry"keepassxc-cli ls <database.kdbx>keepassxc-cli not found (CLI mode only)keepassxc-cli is in your PATHdbPath value — it's resolved relative to the working directoryFAQs
Varlock plugin to load secrets from KeePass databases (KDBX 4.0) and KeePassXC desktop app
The npm package @varlock/keepass-plugin receives a total of 300 weekly downloads. As such, @varlock/keepass-plugin popularity was classified as not popular.
We found that @varlock/keepass-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.