This tutorials shows you how to write and read hocon configuration file format in NodeJS javascript.

E:\work\nodejs-toml-examples> npm i hocon-parser

added 1 package, removed 8 packages, and audited 5 packages in 3s 

found 0 vulnerabilities

How to read Hocon Configuration file in Javascript

const parser = require('hocon-parser');
const fs = require('fs');

try {

    const configFile = 'config.hocon';
    // Read configuration from HOCON file
    const data = fs.readFileSync(configFile, 'utf8');

    // Convert the data into HOCON object
    const obj = parser(data);

    // Read hocon configuration values
    console.log('Database :', obj.database);
    console.log('Database URL:', obj.database.url);
    console.log('Database Username:', obj.database.username);
    console.log('Database Password:', obj.database.password);

} catch (err) {
    console.error(` Failed to parse HOCON file`, err)
}

How to write object to hocon file in Nodejs

There is no support for writing objects to Hocon files currently. You can create a sj