An open API service indexing awesome lists of open source software.

https://github.com/purpledoubled/json-fmt

JSON Swiss Army Knife - format, minify, convert to env/yaml
https://github.com/purpledoubled/json-fmt

cli converter devtools formatter json typescript yaml

Last synced: 3 months ago
JSON representation

JSON Swiss Army Knife - format, minify, convert to env/yaml

Awesome Lists containing this project

README

          

# json-fmt 🛠️

**JSON Swiss Army Knife** — Format, minify, and convert JSON to .env or YAML from the command line.

## Install

```bash
npm install -g json-fmt
```

## Usage

```bash
# Format JSON (pretty print)
echo '{"name":"test","value":123}' | json-fmt

# Minify JSON
echo '{"name":"test","value":123}' | json-fmt --minify

# Convert JSON to .env
echo '{"name":"test","value":123}' | json-fmt --to-env

# Convert JSON to YAML
echo '{"name":"test","value":123}' | json-fmt --to-yaml

# Custom indent (2 or 4)
echo '{"a":1}' | json-fmt -i 4
```

## Options

| Flag | Description |
|------|-------------|
| `-f`, `--format` | Format JSON (default) |
| `-m`, `--minify` | Minify JSON |
| `--to-env` | Convert JSON to .env format |
| `--to-yaml` | Convert JSON to YAML |
| `-i`, `--indent` | Indentation (2 or 4) |
| `-h`, `--help` | Show help |

## Examples

### From file
```bash
json-fmt data.json
json-fmt data.json --minify > data.min.json
```

### Pipe chain
```bash
curl -s https://api.example.com/data | json-fmt | jq '.data'
```

## License

MIT