Skip to content

yq

A command-line tool for reading and editing YAML, JSON, XML, CSV and other data files.

Stars
16.2k
Forks
2.1k
Licence
MIT
Language
Go
Last update
9 days ago
Type
CLI

What it is

yq is a command-line program that reads structured data files such as YAML, JSON, XML, CSV, TSV, INI and properties, and lets you pull out or change values using a jq-like query syntax. People use it in scripts, build pipelines and config management to inspect or update settings without editing files by hand. The README describes it as a lightweight, dependency-free binary written in Go.

  • Read a nested value from a YAML file, for example with yq '.a.b[0].c' file.yaml
  • Update a value in place with yq -i and a set expression
  • Set a value from an environment variable using strenv()
  • Merge multiple YAML files into one output
  • Convert a JSON file to pretty-printed YAML

Great for

  • Developers who regularly edit YAML config files in scripts or CI pipelines
  • DevOps engineers updating Kubernetes or deployment manifests from the command line
  • Anyone converting between formats, such as JSON to YAML or XML to YAML
  • People already familiar with jq who want similar syntax for YAML

Not ideal for

  • Users who need full jq compatibility, since the README says it does not yet support everything jq does
  • People who only edit files in a text editor and never script changes
  • Anyone needing a graphical interface, as this is a command-line tool only
Step-by-step guide: how to use yqInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    Install with Homebrew (macOS / Linux)

    brew install yq

    Install with Snap (Linux)

    snap install yq

    Install with Go

    go install github.com/mikefarah/yq/v4@latest
  2. 2

    Run it

    • Install yq using one of the methods listed in the README
    • Run yq --version to confirm the install worked
    • Read a value with yq '.a.b[0].c' file.yaml, replacing the path with one from your own file
    • Update a file in place with yq -i '.a.b[0].c = "cool"' file.yaml
  3. 3

    Get the most out of it

    • Use strenv(NAME) with NAME set in your environment to inject values into files
    • Merge several files with the ea command and a glob pattern, as shown in the README
    • Use -o json or -o yaml to convert between formats
    • Run it through Docker or Podman with the README's example commands if you do not want a local install
    • Browse the linked recipes and gitbook documentation for more examples

Downloads

Strengths

  • Single downloadable binary with no dependencies, according to the README
  • Supports many formats beyond YAML, including JSON, XML, CSV and TOML per the description
  • Familiar jq-style syntax for users who already know jq

Trade-offs

  • Does not yet implement everything jq does, per the README
  • Some install routes, such as the Debian package, are noted as no longer maintained
  • The README excerpt is truncated, so some details of supported formats and options are not fully covered here

How it compares

ProjectStarsTypeLevelUpdatedBest for
yq (this)16.2kCLIbeginner9 days agoDevelopers who regularly edit YAML config files in scripts or CI pipelines
cli24.3kLibraryintermediate5 days agoGo developers writing a command line tool with subcommands and flags
oh-my-posh23.7kDev toolintermediate5 days agoDevelopers who want their terminal prompt to show extra context
telegraf17.9kAppintermediate4 days agoEngineers setting up server or system monitoring
gjson15.6kLibrarybeginner1 months agoGo developers who need a few fields from a JSON response without writing struct definitions
go13.9kLibrarybeginner2.4 years agoGo developers who parse or produce large amounts of JSON and want to test a faster option

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.