Skip to main content

yq CLI reference

ModularPipelines.Yq provides strongly typed access to the yq CLI.

Executable prerequisite​

This package does not install the yq executable. Install it separately and ensure yq is available on PATH.

Follow the executable's official documentation for installation instructions.

Package installation​

dotnet add package ModularPipelines.Yq

Resolve the service with context.Tools.Yq. Projects using C# 13 or another .NET language can use context.Tools.Get<ModularPipelines.Yq.Services.IYq>() instead.

Module example​

Resolve the service in a module, then select a command from the table below. A runnable example is omitted when no command has complete safety metadata:

var yq = context.Tools.Yq;

Global options​

Global options are rendered before the selected subcommand.

CLI optionPropertyAvailabilityDescription
--colorsColorsAll editionsforce print with colors
--csv-auto-parseCsvAutoParseAll editionsparse CSV YAML/JSON values (default true)
--csv-separatorCsvSeparatorAll editionsCSV Separator character (default ,)
--debug-node-infoDebugNodeInfoAll editionsdebug node info
--exit-statusExitStatusAll editionsset exit status if there are no matches or null or false is returned
--expressionExpressionAll editionsforcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.
--from-fileFromFileAll editionsLoad expression from specified file.
--front-matterFrontMatterAll editions(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-preprocessHeaderPreprocessAll editionsSlurp any header comments and separators before processing expression. (default true)
--indentIndentAll editionssets indent level for output (default 2)
--ini-preserve-quotesIniPreserveQuotesAll editionspreserve surrounding quotes on INI values during round-trip
--inplaceInplaceAll editionsupdate the file in place of first file given.
--input-formatInputFormatAll editions[auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|base64url|uri|toml|hcl|h|lua|l|ini|i] parse format for input. (default "auto")
--lua-globalsLuaGlobalsAll editionsoutput keys as top-level global variables
--lua-prefixLuaPrefixAll editionsprefix (default "return ")
--lua-suffixLuaSuffixAll editionssuffix (default ";\n")
--lua-unquotedLuaUnquotedAll editionsoutput unquoted string keys (e.g. {foo="bar"})
--no-colorsNoColorsAll editionsforce print with no colors
--no-docNoDocAll editionsDon't print document separators (---)
--nul-outputNulOutputAll editionsUse NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
--null-inputNullInputAll editionsDon't read input, simply evaluate the expression given. Useful for creating docs from scratch.
--output-formatOutputFormatAll editions[auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|base64url|uri|toml|hcl|h|shell|s|lua|l|ini|i] output format type. (default "auto")
--prettyPrintPrettyPrintAll editionspretty print, shorthand for '... style = ""'
--properties-array-bracketsPropertiesArrayBracketsAll editionsuse [x] in array paths (e.g. for SpringBoot)
--properties-separatorPropertiesSeparatorAll editionsseparator to use between keys and values (default " = ")
--security-disable-env-opsSecurityDisableEnvOpsAll editionsDisable env related operations.
--security-disable-file-opsSecurityDisableFileOpsAll editionsDisable file related operations (e.g. load)
--security-enable-system-operatorSecurityEnableSystemOperatorAll editionsEnable system operator to allow execution of external commands.
--shell-key-separatorShellKeySeparatorAll editionsseparator for shell variable key paths (default "_")
--split-expSplitExpAll editionsprint 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.
--split-exp-fileSplitExpFileAll editionsUse a file to specify the split-exp expression.
--string-interpolationStringInterpolationAll editionsToggles strings interpolation of (exp) (default true)
--tsv-auto-parseTsvAutoParseAll editionsparse TSV YAML/JSON values (default true)
--unwrapScalarUnwrapScalarAll editionsunwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (default true)
--verboseVerboseAll editionsverbose mode
--xml-attribute-prefixXmlAttributePrefixAll editionsprefix for xml attributes (default "+@")
--xml-content-nameXmlContentNameAll editionsname for xml content (if no attribute name is present). (default "+content")
--xml-directive-nameXmlDirectiveNameAll editionsname for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
--xml-keep-namespaceXmlKeepNamespaceAll editionsenables keeping namespace after parsing attributes (default true)
--xml-proc-inst-prefixXmlProcInstPrefixAll editionsprefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_")
--xml-raw-tokenXmlRawTokenAll editionsenables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
--xml-skip-directivesXmlSkipDirectivesAll editionsskip over directives (e.g. <!DOCTYPE thing cat>)
--xml-skip-proc-instXmlSkipProcInstAll editionsskip over process instructions (e.g. <?xml version="1"?>)
--xml-strict-modeXmlStrictModeAll editionsenables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.
--yaml-compact-seq-indentYamlCompactSeqIndentAll editionsUse compact sequence indentation where '- ' is considered part of the indentation.
--yaml-fix-merge-anchor-to-specYamlFixMergeAnchorToSpecAll editionsFix merge anchor to match YAML spec. Will default to true in late 2025

Commands​

CLI commandOptions record
yq evalYqEvalOptions
yq eval-allYqEvalAllOptions