Skip to main content


Synchronous provider that loads data from TOML files.

TOML is a simple configuration file format that's easy to read and write. Definitely much better than JSON or ENV variables.

Using TOML provider has multiple benefits:

  • TOML files are easy to read and write
  • TOML provider supports merging multiple config files into one final configuration which allows to split configuration into smaller files
  • TOML is much better approach for advanced configuration structures


npm install @pallad/config-toml


import {tomlProviderFactory} from '@pallad/config-toml';

const toml = tomlProviderFactory({
files: [
'config.toml', // required file
{path: '', required: false} // optional file

// retrieves "database.password" parameter

And example config file

password = 'test'


Validation of entire config


Validation of single value

Easiest way to validate single value is to use transform method. See transform provider docs for further customization options.

import {type} from '@pallad/config';


Deep merge

TOML provider uses deepmerge library to merge loaded config into one final object.

For example by default arrays are merged together instead of being replaced by one another. You can customize that behavior by providing deepMerge option to provider factory.

import {tomlProviderFactory} from "@pallad/config-toml"; 
const toml = tomlProviderFactory({
files: ['config.toml'],
deepMerge: {
arrayMerge: (destinationArray, sourceArray, options) => sourceArray // overrides previous array with new one

Overriding values

Since config is merge to one final object and files further down in the list have higher priority then previous ones you can easily create developer friendly system to override values.

import {tomlProviderFactory} from '@pallad/config-toml';

const toml = tomlProviderFactory({
files: [
{path: '', required: false},

host = ''

At this stage is But if you provide with the same key it will override it.
host = ''