Blossom Logo Deploy your apps with Heroku-like simplicity using Blossom See Your Savings
BoltOps Logo
JSON to YAML One Liner header image

JSON to YAML One Liner

Tung Nguyen Tung Nguyen · September 16, 2017 · 1 min read

I don’t remember exactly where I got these one-liners from anymore. It’s been in my expander for a while. Here are useful oneliners to convert JSON to YAML and vice versa.

JSON to YAML (stdout):

ruby -ryaml -rjson -e 'puts YAML.dump(JSON.load(ARGF))' < example.json

JSON to YAML (redirect to file):

ruby -ryaml -rjson -e 'puts YAML.dump(JSON.load(ARGF))' < example.json > example.yml

YAML to JSON (stdout):

ruby -ryaml -rjson -e 'puts YAML.dump(JSON.load(ARGF))' < example.yml

YAML to JSON (redirect to file):

ruby -ryaml -rjson -e 'puts YAML.dump(JSON.load(ARGF))' < example.yml > example.json

Hope you found this helpful! 🎉

Blossom Logo
Deploy Your Apps with Ease

Blossom lets you deploy to your own servers with Heroku-like simplicity. Connect any cloud provider and we'll handle the rest. Save time and money with Blossom.

BoltOps Blog
Join a group of good-looking folks who get free email updates from BoltOps.