Scroll to navigation

YQ(1) User Commands YQ(1)

NAME

yq - portable command-line YAML, JSON, XML, CSV, TOML, HCL and properties processor

DESCRIPTION

yq is a portable command-line data file processor (https://github.com/mikefarah/yq/) See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.

Usage:

yq [flags] yq [command]

EXAMPLES

# yq tries to auto-detect the file format based off the extension, and defaults to YAML if it's unknown (or piping through STDIN) # Use the '-p/--input-format' flag to specify a format type. cat file.xml | yq -p xml

# read the "stuff" node from "myfile.yml" yq '.stuff' < myfile.yml

# update myfile.yml in place yq -i '.stuff = "foo"' myfile.yml

# print contents of sample.json as idiomatic YAML yq -P -oy sample.json

Available Commands:

Generate the autocompletion script for the specified shell
(default) Apply the expression to each document in each yaml file in sequence
eval-all
Loads _all_ yaml documents of _all_ yaml files and runs expression once
Help about any command

Flags:

force print with colors
parse CSV YAML/JSON values (default true)
CSV Separator character (default ,)
debug node info
set exit status if there are no matches or null or false is returned
forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.
Load expression from specified file.
(extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact
Slurp any header comments and separators before processing expression. (default true)
help for yq
sets indent level for output (default 2)
update the file in place of first file given.
[auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|lua|l|ini|i] parse format for input. (default "auto")
output keys as top-level global variables
prefix (default "return ")
suffix (default ";\n")
output unquoted string keys (e.g. {foo="bar"})
force print with no colors
Don't print document separators (---)
-0, --nul-output
Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.
[auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|shell|s|lua|l|ini|i] output format type. (default "auto")
pretty print, shorthand for '... style = ""'
use [x] in array paths (e.g. for SpringBoot)
separator to use between keys and values (default " = ")
Disable env related operations.
Disable file related operations (e.g. load)
Enable system operator to allow execution of external commands.
separator for shell variable key paths (default "_")
print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.
Use a file to specify the split-exp expression.
Toggles strings interpolation of \(exp) (default true)
parse TSV YAML/JSON values (default true)
unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (default true)
verbose mode
Print version information and quit
prefix for xml attributes (default "+@")
name for xml content (if no attribute name is present). (default "+content")
name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
enables keeping namespace after parsing attributes (default true)
prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_")
enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
skip over directives (e.g. <!DOCTYPE thing cat>)
skip over process instructions (e.g. <?xml version="1"?>)
enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.
Use compact sequence indentation where '- ' is considered part of the indentation.
Fix merge anchor to match YAML spec. Will default to true in late 2025

Use "yq [command] --help" for more information about a command.

SEE ALSO

The full documentation for yq is maintained as a Texinfo manual. If the info and yq programs are properly installed at your site, the command

info yq

should give you access to the complete manual.

May 2026 https://github.com/mikefarah/yq/ version v4.53.2