Skip to content
Easily load and persist config without having to think about where and how
Branch: master
Clone or download
Latest commit 764ac63 Jun 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Tidelift tasks May 31, 2019
.editorconfig Bump dependencies and switch to `make-dir` May 10, 2017
.gitattributes Require Node.js 6 Jul 28, 2018
.gitignore Add license file Mar 26, 2018
.npmrc Add license file Mar 26, 2018
.travis.yml Fix Travis Jun 12, 2019
index.js Require Node.js 8 Jun 11, 2019
license Require Node.js 6 Jul 28, 2018
package.json 5.0.0 Jun 11, 2019 Require Node.js 8 Jun 11, 2019
test.js Meta tweaks Mar 28, 2019

configstore Build Status

Easily load and persist config without having to think about where and how

The config is stored in a JSON file located in $XDG_CONFIG_HOME or ~/.config.
Example: ~/.config/configstore/some-id.json

If you need this for Electron, check out electron-store instead.
And check out conf for an updated approach to this concept.


$ npm install configstore


const Configstore = require('configstore');
const packageJson = require('./package.json');

// Create a Configstore instance
const config = new Configstore(, {foo: 'bar'});

//=> 'bar'

config.set('awesome', true);
//=> true

// Use dot-notation to access nested properties
config.set('bar.baz', true);
//=> {baz: true}

//=> undefined


Configstore(packageName, defaults?, options?)

Returns a new instance.


Type: string

Name of your package.


Type: object

Default config.


Type: object


Type: boolean
Default: false

Store the config at $CONFIG/package-name/config.json instead of the default $CONFIG/configstore/package-name.json. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.


Type: string
Default: Automatic

Please don't use this option unless absolutely necessary and you know what you're doing.

Set the path of the config file. Overrides the packageName and globalConfigPath options.


You can use dot-notation in a key to access nested properties.

.set(key, value)

Set an item.


Set multiple items at once.


Get an item.


Check if an item exists.


Delete an item.


Delete all items.


Get the item count.


Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.


Get all the config as an object or replace the current config with an object:

config.all = {
	hello: 'world'

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
You can’t perform that action at this time.