# json2yaml

> A commandline utility to convert JSON to YAML / YML

Latest version **1.1.0** (published 2016-04-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install json2yaml
pnpm add json2yaml
yarn add json2yaml
bun add json2yaml
```

Provides the commands `json2yml`, `json2yaml`, `jsontoyml`, `jsontoyaml`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2016-04-19 |
| First published | 2012-01-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.2.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 90 |
| Author | AJ ONeal |
| Maintainers | coolaj86 |
| Keywords | yml, yaml, json, cli, util |

## Links

- npm: https://www.npmjs.com/package/json2yaml
- Repository: https://github.com/coolaj86/json2yaml
- Homepage: https://github.com/coolaj86/json2yaml#readme
- Issues: https://github.com/coolaj86/json2yaml/issues
- npm.io page: https://npm.io/package/json2yaml

## Dependencies (1)

- [remedial](https://npm.io/package/remedial.md) 1.x

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.0 (latest) — 2016-04-19
- 1.0.3 — 2013-08-02
- 1.0.2 — 2013-07-28
- 1.0.1 — 2012-01-31
- 1.0.0 — 2012-01-30

## README

json2yaml
===

A command-line utility to convert JSON to YAML (meaning a `.json` file to a `.yml` file)

The purpose of this utility is to pretty-print JSON in the human-readable YAML object notation
(ignore the misnomer, YAML is not a Markup Language at all).

Installation
===

```bash
npm install -g json2yaml
```

*Note*: To use `npm` and `json2yaml` you must have installed [NodeJS](http://nodejs.org#download).

Usage
---

Specify a file:

```bash
json2yaml ./example.json > ./example.yml

yaml2json ./example.yml | json2yaml > ./example.yml
```

Or pipe from stdin:

```bash
curl -s http://foobar3000.com/echo/echo.json | json2yaml

wget -qO- http://foobar3000.com/echo/echo.json | json2yaml
```

Or require:

```javascript
(function () {
  "use strict";

  var YAML = require('json2yaml')
    , ymlText
    ;

    ymlText = YAML.stringify({
      "foo": "bar"
    , "baz": "corge"
    });

    console.log(ymlText);
}());
```

Example
===

So, for all the times you want to turn JSON int YAML (YML):

```javascript
{ "foo": "bar"
, "baz": [
    "qux"
  , "quxx"
  ]
, "corge": null
, "grault": 1
, "garply": true
, "waldo": "false"
, "fred": "undefined"
}
```

becomes

```yaml
---
  foo: "bar"
  baz:
    - "qux"
    - "quxx"
  corge: null
  grault: 1
  garply: true
  waldo: "false"
  fred: "undefined"
```

*Note*: In fact, both of those Object Notations qualify as YAML
because JSON technically *is* a proper subset of YAML.
That is to say that all proper YAML parsers parse proper JSON.

YAML can use either *whitespace and dashes* or *brackets and commas*.

For human readability, the whitespace-based YAML is preferrable.
For compression and computer readability, the JSON syntax of YAML is preferrable.

Alias
===

`json2yaml` has the following aliases:

  * `jsontoyaml`
  * `json2yml`
  * `jsontoyml`

---
_Source: https://npm.io/package/json2yaml · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
