JavaScript configuration libraries

Updated Nov 2026

JavaScript configuration libraries load an application's settings from environment variables, .env files, and config files. A loader searches known file locations and merges the values it finds into one settings object. These libraries keep API keys, ports, feature flags, and user preferences out of application code.

Popularity

dotenv has the most monthly downloads in this comparison, at 1.0B.

LibraryMonthly downloadsStarsLast releaseLicense
dotenv
1.0B
20.6KNov 2026BSD-2-Clause
Cosmiconfig
667.8M
Not on GitHubAug 2026MIT
ConfigArray
601.0M
Not on GitHubNov 2026Apache-2.0
Lilconfig
403.3M
Not on GitHubNov 2026MIT
rc
225.5M
Not on GitHubMay 2018(BSD-2-Clause OR MIT OR Apache-2.0)
c12
152.4M
Not on GitHubOct 2026MIT
Conf
99.1M
Not on GitHubOct 2026MIT
Configstore
98.0M
Not on GitHubJan 2026BSD-2-Clause
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryYAML config filesSchema validationPer-file overridesWrites config filesBuilt-in .env loader
dotenvUnsupportedUnsupportedUnsupportedUnsupportedBuilt-in
CosmiconfigBuilt-inUnsupportedUnsupportedUnsupportedUnsupported
ConfigArrayUnsupportedBuilt-inBuilt-inUnsupportedUnsupported
LilconfigVia pluginUnsupportedUnsupportedUnsupportedUnsupported
rcUnsupportedUnsupportedUnsupportedUnsupportedUnsupported
c12Built-inBuilt-inUnsupportedVia pluginBuilt-in
ConfVia pluginBuilt-inUnsupportedBuilt-inUnsupported
ConfigstoreUnsupportedUnsupportedUnsupportedBuilt-inUnsupported
Built-inVia pluginNot supported

Libraries and code examples

Loads environment-file values into process.env or a supplied target object.

Downloads / mo
1.0B
Stars
20.6K
Last release
18.0.10
License
BSD-2-Clause

Strengths

  • Loads environment files directly. Load file values early in application startup.
  • Supports a separate target object. Pass processEnv to populate a supplied object instead of process.env.

Limitations

  • Existing values win by default. Set override to replace variables already present in the target.
  • Variable expansion needs another tool. Use a separate expansion package for references between variables.

Quickstart

From README.md
$ npm install dotenv@18.0.10
// Explicit fixture: create .env containing HELLO="Dotenv" first.
import dotenv from 'dotenv';

dotenv.config();
console.log(process.env.HELLO);

dotenv examples

From open-source projects on GitHub
export function loadRootEnvFiles(root = workspaceRoot) {
  const myEnv = loadDotEnvFile({
    path: ['.local.env', '.env.local', '.env'].map((file) => join(root, file)),
  });
  expand(myEnv);
}

Searches for and loads a program's configuration.

Downloads / mo
667.8M
Last release
10.0.1
License
MIT

Strengths

  • Reads JSON, YAML, and JS rc files. An rc file can be JSON, YAML, JavaScript, or TypeScript.
  • Reads package.json properties. A property in package.json can hold the configuration instead of a file.

Quickstart

From README.md
$ npm install cosmiconfig@10.0.1
import { cosmiconfig } from 'cosmiconfig';

const explorer = cosmiconfig('myapp');
const result = await explorer.search();

Cosmiconfig examples

From open-source projects on GitHub

Matches configuration objects to files by glob patterns on their filenames.

Downloads / mo
601.0M
Last release
0.23.6
License
Apache-2.0

Strengths

  • Works outside ESLint. The package carries no ESLint-specific functionality.
  • Later objects override earlier ones. A config object later in the array overrides the objects before it.

Quickstart

From README.md
$ npm install @eslint/config-array@0.23.6
import path from 'node:path';
import { ConfigArray } from '@eslint/config-array';

const configs = new ConfigArray([{ files: ['**/*.js'], enabled: true }], {
  basePath: process.cwd(),
  schema: { enabled: {
    merge: (a, b) => b ?? a,
    validate(value) {
      if (typeof value !== 'boolean') throw new TypeError('Boolean expected.');
    },
  } },
});
configs.normalizeSync();
const config = configs.getConfig(path.resolve('example.js'));

ConfigArray examples

From open-source projects on GitHub

Provides a zero-dependency alternative to Cosmiconfig with the same API.

Downloads / mo
403.3M
Last release
3.1.5
License
MIT

Limitations

  • No YAML by default. Add a loader to read YAML files.
  • ESM needs the async API. ESM config files load only through the asynchronous API.

Quickstart

From readme.md
$ npm install lilconfig@3.1.5
import { lilconfig } from 'lilconfig';

const result = await lilconfig('myapp').search();

Lilconfig examples

From open-source projects on GitHub
async function postCssFindConfig(path: string, options: Options = {}) {
  const result = await config.lilconfig('postcss', withLoaders(options)).search(path);

  return result ? result.filepath : null;
}

Returns an app's configuration merged with the defaults it specifies.

Downloads / mo
225.5M
Last release
1.2.8
License
(BSD-2-Clause OR MIT OR Apache-2.0)

Strengths

  • Records the files it read. The returned object lists the path of every config file found.

Limitations

  • Mutates a passed defaults object. Pass a fresh object when the defaults must stay unchanged.

Quickstart

From README.md
$ npm install rc@1.2.8
import rc from 'rc';

const config = rc('myapp', { port: 3000 });

rc examples

From open-source projects on GitHub

Merges configuration from multiple sources into one object.

Downloads / mo
152.4M
Last release
4.0.0-rc.4
License
MIT

Strengths

  • Reloads on change. A config watcher reloads settings when a config file changes.
  • Loads .env files. .env files load with variable interpolation.

Limitations

  • Major upgrade needs migration. Follow the migration guide when upgrading between major versions.

Quickstart

From README.md
$ npm install c12@4.0.0-rc.4
import { loadConfig } from 'c12';

const { config } = await loadConfig({});

Persists small app settings to a JSON file without the app choosing where or how.

Downloads / mo
99.1M
Last release
16.0.0
License
MIT

Limitations

  • One writer at a time. Avoid writing to the same store from two processes at once.
  • Rewrites the whole file. Keep the store small, such as user settings that change occasionally.

Quickstart

From readme.md
$ npm install conf@16.0.0
import Conf from 'conf';

const config = new Conf({ projectName: 'my-app' });
config.set('enabled', true);

Loads and saves app settings in a JSON file under the user's config directory.

Downloads / mo
98.0M
Last release
8.0.0
License
BSD-2-Clause

Limitations

  • Superseded by Conf. The authors point new projects to Conf as the newer version.

Quickstart

From readme.md
$ npm install configstore@8.0.0
import Configstore from 'configstore';

const config = new Configstore('my-app');
config.set('enabled', true);

Configstore examples

From open-source projects on GitHub

FAQ

dotenv loads the key and value pairs in a .env file into process.env, or into an object the app supplies. Without override, a value already present in process.env is left unchanged.

Node.js exposes environment variables on process.env. dotenv fills process.env from a .env file at startup. c12 loads .env files together with config files.

Cosmiconfig searches for and loads a program's configuration from a package.json property or an rc file in JSON, YAML, or JavaScript.

c12 loads .env files with variable interpolation and merges them with config files. rc reads prefixed environment variables alongside command-line arguments and config files.

Its own README directs variable expansion to a separate tool.

Pass a custom processEnv target to receive the loaded values.

For coding agents

Found your configuration library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official