Blossom Logo Deploy your apps with Blossom — Get Started
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 helps you and your AI agent deploy apps and keep them running. Start on managed Blossom Cloud or connect your own cloud account.

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