YQ(1)

๐Ÿ“ฆ version 4.53.3, in ubuntu stonking

๐Ÿ’– 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 (default true)
  • --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. (default true)
  • -h, --help โ€” help for yq ๐Ÿซถ
  • -I, --indent int โ€” sets indent level for output (default 2)
  • --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 $index in 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) (default true)
  • --tsv-auto-parse โ€” parse TSV YAML/JSON values (default true)
  • -r, --unwrapScalar โ€” unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (default true)
  • -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 (default true)
  • --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. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
  • --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. See https://pkg.go.dev/encoding/xml for 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