YQ(1)
๐ YQ ๐
okay so bestie, this is yq(1) โ from the User Commands crew โ and it's about to become your entire personality. no fr, this one's a keeper.
โจ NAME โจ
yq โ the portable command-line processor for YAML, JSON, XML, CSV, TOML, HCL and properties files. one tool, all the formats, main character energy ๐
๐ธ DESCRIPTION ๐ธ
yq is a portable command-line data file processor โ you can find it over at https://github.com/mikefarah/yq/ ๐ซถ
for all the detailed documentation and examples your little heart desires, go look at https://mikefarah.gitbook.io/yq/ โจ
๐ฆ Usage ๐ฆ
yq [flags] yq [command]
๐ EXAMPLES ๐
okay so first thing you gotta know: yq tries to auto-detect the file format based off the extension, and it defaults to YAML if that extension is unknown (or if you're piping through STDIN, iykyk). and if auto-detect isn't giving, you can always specify a format type yourself with the -p/--input-format flag. ๐
cat file.xml | yq -p xml
reading the "stuff" node out of "myfile.yml"? literally one line bestie:
yq '.stuff' < myfile.yml
updating myfile.yml in place (yes, in place, be careful, no take-backs):
yq -i '.stuff = "foo"' myfile.yml
and printing the contents of sample.json as idiomatic YAML? slay:
yq -P -oy sample.json
๐ Available Commands ๐
completionโ generate the autocompletion script for the specified shell. go set it up, your future self says thank you โจevalโ the default one. applies the expression to each document in each yaml file, in sequence. one at a time, no rushing ๐eval-allโ loads all the yaml documents of all the yaml files and runs the expression once. the whole group chat at once, periodt ๐ซถhelpโ help about any command. it's giving supportive bestie ๐ญ
๐ Flags ๐
-C,--colorsโ force print with colors ๐จ--csv-auto-parseโ parse CSV YAML/JSON values (defaulttrue)--csv-separator charโ CSV Separator character (default,)--debug-node-infoโ debug node info ๐-e,--exit-statusโ set exit status if there are no matches or null or false is returned--expression stringโ forcibly set the expression argument. super useful when yq's argument detection thinks your expression is a file ๐--from-file stringโ Load expression from specified file.-f,--front-matter stringโ(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 โจ--header-preprocessโ Slurp any header comments and separators before processing expression. (defaulttrue)-h,--helpโ help for yq ๐ซถ-I,--indent intโ sets indent level for output (default2)--ini-preserve-quotesโ preserve surrounding quotes on INI values during round-trip-i,--inplaceโ update the file in place of first file given. โ ๏ธ this one edits your actual file, no cap, so maybe keep a backup bestie-p,--input-format stringโ parse format for input, one of[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](default"auto")--lua-globalsโ output keys as top-level global variables--lua-prefix stringโ prefix (default"return ")--lua-suffix stringโ suffix (default";\n")--lua-unquotedโ output unquoted string keys (e.g.{foo="bar"})-M,--no-colorsโ force print with no colors ๐ซ๐จ-N,--no-docโ 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.-n,--null-inputโ Don't read input, simply evaluate the expression given. Useful for creating docs from scratch ๐ฑ-o,--output-format stringโ output format type, one of[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](default"auto")-P,--prettyPrintโ pretty print, shorthand for'... style = ""'๐--properties-array-bracketsโ use[x]in array paths (e.g. for SpringBoot)--properties-separator stringโ separator to use between keys and values (default" = ")--security-disable-env-opsโ Disable env related operations.--security-disable-file-opsโ Disable file related operations (e.g.load)--security-enable-system-operatorโ Enable system operator to allow execution of external commands. ๐--shell-key-separator stringโ separator for shell variable key paths (default"_")-s,--split-exp stringโ print each result (or doc) into a file named (exp). The[exp]argument must return a string. You can use$indexin the expression as the result counter. The necessary directories will be created. ๐๏ธ--split-exp-file stringโ Use a file to specify the split-exp expression.--string-interpolationโ Toggles strings interpolation of\(exp)(defaulttrue)--tsv-auto-parseโ parse TSV YAML/JSON values (defaulttrue)-r,--unwrapScalarโ unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (defaulttrue)-v,--verboseโ verbose mode ๐ฃ๏ธ-V,--versionโ Print version information and quit--xml-attribute-prefix stringโ prefix for xml attributes (default"+@")--xml-content-name stringโ name for xml content (if no attribute name is present). (default"+content")--xml-directive-name stringโ name for xml directives (e.g.<!DOCTYPE thing cat>) (default"+directive")--xml-keep-namespaceโ enables keeping namespace after parsing attributes (defaulttrue)--xml-proc-inst-prefix stringโ prefix for xml processing instructions (e.g.<?xml version="1"?>) (default"+p_")--xml-raw-tokenโ enables using RawToken method instead Token. Commonly disables namespace translations. Seehttps://pkg.go.dev/encoding/xml#Decoder.RawTokenfor details. (defaulttrue)--xml-skip-directivesโ skip over directives (e.g.<!DOCTYPE thing cat>)--xml-skip-proc-instโ skip over process instructions (e.g.<?xml version="1"?>)--xml-strict-modeโ enables strict parsing of XML. Seehttps://pkg.go.dev/encoding/xmlfor more details.-c,--yaml-compact-seq-indentโ Use compact sequence indentation where'- 'is considered part of the indentation.--yaml-fix-merge-anchor-to-specโ Fix merge anchor to match YAML spec. Will default to true in late 2025 ๐ฎ
and if you get lost (you won't, you got this), just run 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. go get that lore bestie ๐โจ
that's the whole vibe ๐ this page comes to you from https://github.com/mikefarah/y..., dated August 2026, and it lives in section YQ(1). go forth and process all the formats, you absolute icon ๐๐ฆ๐
๐ฆ where this page comes from
- ubuntu stonking: yq-go 4.53.3+ds-2 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms