explaingit

mikefarah/yq

15,387GoAudience · ops devopsComplexity · 1/5Setup · easy

TLDR

A command-line tool for reading, editing, and converting config files, YAML, JSON, XML, TOML, CSV, and more, with simple one-line commands using jq-style path syntax.

Mindmap

mindmap
  root((yq))
    What it does
      Read config values
      Edit files in place
      Convert between formats
    Formats supported
      YAML JSON XML
      TOML CSV TSV INI
    Use cases
      Kubernetes manifests
      CI pipelines
      Helm values
      Config scripting
    Installation
      Single binary download
      Homebrew snap Docker
      Chocolatey Windows
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Extract or update a value in a Kubernetes YAML manifest without opening an editor.

USE CASE 2

Convert a JSON config file to pretty-printed YAML (or vice versa) in one terminal command.

USE CASE 3

Substitute environment variables into a config file as part of a CI/CD pipeline script.

USE CASE 4

Merge two or more YAML files together and search or filter the combined result.

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

yq is a small command-line tool for reading and editing structured configuration files. It handles YAML, JSON, XML, CSV, TSV, TOML, HCL, INI, and Java-style properties files. The pitch is that you can pull a value out of a config file, change a setting, or convert between formats with one terminal command instead of writing a script. Its syntax is borrowed from jq, a popular tool for working with JSON, so a path like .a.b[0].c reads the value of c in the first item of list b inside object a. The README shows the common patterns: reading a value, updating a file in place with the -i flag, substituting environment variables into the file, merging two or more files into one, finding an item in an array by a field and updating it, and converting between formats, for example dumping JSON as pretty-printed YAML, or XML as YAML. There is also a GitHub Action wrapper so you can run the same commands inside a continuous-integration workflow. You would reach for yq when you are working with DevOps configuration, Kubernetes manifests, CI pipelines, Ansible inventories, Helm values, application config files, and want a quick, scriptable way to inspect or change them without opening an editor. It is written in Go and ships as a single dependency-free binary, which means you can drop it onto any machine and run it without installing a runtime. The README lists many ways to install it: direct binary download, Homebrew on macOS and Linux, snap, Docker and Podman images, a Nix package, an Arch package, Chocolatey on Windows, and go install. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
Using yq, write a shell command to update the image tag in a Kubernetes deployment YAML from 'latest' to a specific version string.
Prompt 2
Show me how to use yq to extract the value of .spec.replicas from a Kubernetes YAML file and store it in a bash variable.
Prompt 3
Write a yq command to merge two Helm values files so the second file's values override the first.
Prompt 4
How do I use yq in a GitHub Actions workflow to substitute environment variables into a config YAML template file?
Prompt 5
Give me a yq one-liner to convert a JSON API response file to clean YAML output.
Open on GitHub → Explain another repo

← mikefarah on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.