json-to-pretty-yaml
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/json-to-pretty-yaml package

1.2.2 • Public • Published

♻️ json-to-pretty-yaml

A node module to convert JSON to pretty YAML

Installation

npm install --save json-to-pretty-yaml

Usage

index.js

const fs = require('fs');
const YAML = require('json-to-pretty-yaml');
const json = require('input.json');
 
const data = YAML.stringify(json);
fs.writeFile('output.yaml', data);

input.json

{
  "a": 1,
  "b": 2,
  "c": [
    {
      "d": "cool",
      "e": "new"
    },
    {
      "f": "free",
      "g": "soon"
    }
  ]
}

output.yaml

a: 1
b: 2
c:
  d: "cool"
    e: "new"
  f: "free"
    g: "soon"

Testing

npm test

Dependents (153)

Package Sidebar

Install

npm i json-to-pretty-yaml

Weekly Downloads

2,317,576

Version

1.2.2

License

Apache-2.0

Unpacked Size

17 kB

Total Files

6

Last publish

Collaborators

  • alexcrist