Load configurations from cli, environment & config files and validate them with a JSON schema


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @datatypes/config in KB



Load configurations from cli, environment and config files and validate them with a JSON schema.

Per default environment variables are understood like this:


gets parsed to

  email: {
    clientId: '123abc',


npm install @datatypes/config


const Config = require('@datatypes/config')
const exampleConfig = new Config({
  appName: 'myapp'

    prefix: 'MYAPP_ALT_NAME_', // Default is MYAPP_
    pathSeparator: '--', // Default is __
    wordSeparator: '-', // Default is _
    casing: 'snake', // Default is camel
    encodeDataUris: false, // Default is true
    absolutePath: '/path/to/config-file.yaml', // Supports .yaml, .json, .js
    isRequired: true // Default is false
    ignoreIsDirectoryError: true, // Default is false
    settingA: 'valueA',
  // Replaces the values which contain a file path
  // of special keys with the file content of the file path
    triggerCharater: '%', // Default @
    shouldTrim: false, // Default true


Default files

With increasing priority:

  • .myapp
  • .myapp{,.json,.yaml}
  • .myapp/config
  • .myapp/config{,.json,.yaml}
  • .config/myapp/config{,.json,.yaml} (This with .yaml is recommended)
  • .config/myapp/myapp{,.json,.yaml}
  • /.myapp{,.json,.yaml}
  • $(pwd)/.myapp{,.json,.yaml}


  • nconf - Hierarchical node.js configuration with files, environment variables, command-line arguments and atomic object merging.
  • node-config - Node.js Application Configuration.
  • node-convict - Unruly configuration management for nodejs.
  • rc - The non-configurable configuration loader for lazy people.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.