Convert yaml to json in script

Postman lists both js-yaml and yaml.js as dependencies.
Is one of them exposed in the scripts?
I would like to convert my openApi yaml to json so that I can validate API responses against their schema’s inside the API spec (the yaml would be fetched from github)

Hello @houbie,

I worked on the same issue and I found a solution. I stored the source code of yaml-js into a global variable using its CDN ( and then I imported it into my request scripts (see the code below):

// Import yaml-js library (stored in global variable)
const yaml = pm.globals.get('yaml-js');
(new Function(yaml))();
// Convert API specifications to JSON (initially in YAML format)
let specs = jsyaml.load(pm.response.text());

Hope it will help!