Convert JSON to YAML

Feb 15, 2022

Below is a converter that transforms JSON into YAML.

In Node.js

To convert JSON to YAML, you should install json-to-pretty-yaml. Use the stringify function() from the npm module to convert the JSON.

const YAML = require('json-to-pretty-yaml');

const json = '{ "a": 1, "b": 2, "c": 3 }';

const data = YAML.stringify(json);

data;
/*
a: 1
b: 2
c: 3
*/

More Tools