XQ(1)

πŸ“¦
version 3.4.3 Β· 2 versions
, in debian trixie, ubuntu resolute

okay bestie, sit down, hydrate, put your phone on do-not-disturb, because we are about to get into xq β€” that's xq(1), filed under User Commands, and honestly? she ate. no notes. πŸ’…


✨ NAME ✨

xq β€” Command-line XML processor β€” jq wrapper for XML documents 🌸


πŸŽ€ SYNOPSIS πŸŽ€

jq [options] <jq filter> [file...]
not me pointing out that the synopsis literally says jq and not xq πŸ’€ that's just what it says, bestie, i don't write the manpages, i just make them cute. 🫢

πŸ¦‹ DESCRIPTION πŸ¦‹

here's the usage, verbatim, because accuracy is the whole personality:

usage: xq [options] <jq filter> [input file...]

       [--version] [jq_filter] [files ...]

xq: Command-line XML processor - jq wrapper for XML documents

so like β€” xq transcodes XML documents to JSON and passes them to jq. that's the whole bit. she's a translator, a hype woman for your XML. ✨

if you want the deep lore, it lives at https://github.com/kislyuk/xq β€” go look, it's giving documentation.

🌈 positional arguments 🌈

  • jq_filter
  • files

πŸ’– options πŸ’–

  • -h, --help β€” show this help message and exit. the classic. the icon. πŸŽ€
  • --xml-output, -x β€” Transcode jq JSON output back into XML and emit it. so you go XML β†’ JSON β†’ jq does her thing β†’ back to XML. a whole round trip, a whole journey. ✈️
  • --xml-item-depth 123 β€” Specify depth of items to emit (default 0; use a positive integer to stream large docs). streaming big docs? slay. πŸ’…
  • --xml-dtd β€” Preserve XML Document Type Definition (disables streaming of multiple docs). heads up bestie: this turns the streaming off, that's not a vibe, that's just the rules. 😭
  • --xml-root XML_ROOT β€” When transcoding back to XML, envelope the output in an element with this name. give your output a little house. 🏠
  • --xml-force-list ELT β€” Emit a list for elements with this name even if they occur only once (option can repeat). yes, she can repeat, she contains multitudes. πŸ”₯
  • --in-place, -i β€” Edit files in place (no backup - use caution). NO BACKUP. USE CAUTION. i'm not being dramatic, the manpage said it, and i'm just repeating it louder because i love you. πŸ™ˆ
  • --version β€” show program's version number and exit. πŸ‘‘

and now, because the original just embeds the entire jq help text in here, we're doing that too. no skipping, no summarising, we're not cowards. 🫢

jq - commandline JSON processor [version 1.7]

jq [options] --args <jq filter> [strings...]  jq [options] --jsonargs <jq filter> [JSON_TEXTS...]

jq is a tool for processing JSON inputs, applying the given filter to its JSON text inputs and producing the filter's results as JSON on standard output. she's efficient, she's precise, she's everything. ⭐

the simplest filter is ., which copies jq's input to its output unmodified except for formatting. honestly? a minimalist queen. πŸ‘‘

for more advanced filters, see the jq(1) manpage (man jq) and/or https://jqlang.github.io/jq/.

Example:

$ echo '{"foo": 0}' | jq .

{

"foo": 0

}
yes, the blank lines are literally in there. i am not cleaning up the original's formatting choices. we respect her house style. πŸ’€

πŸ“ Command options: πŸ“

  • -n, --null-input β€” use null as the single input value;
  • -R, --raw-input β€” read each line as string instead of JSON;
  • -s, --slurp β€” read all inputs into an array and use it as the single input value;
  • -c, --compact-output β€” compact instead of pretty-printed output;
  • -r, --raw-output β€” output strings without escapes and quotes;
  • --raw-output0 β€” implies -r and output NUL after each output;
  • -j, --join-output β€” implies -r and output without newline after each output;
  • -a, --ascii-output β€” output strings by only ASCII characters using escape sequences;
  • -S, --sort-keys β€” sort keys of each object on output;
  • -C, --color-output β€” colorize JSON output;
  • -M, --monochrome-output β€” disable colored output;
  • --tab β€” use tabs for indentation;
  • --indent n β€” use n spaces for indentation (max 7 spaces);
  • --unbuffered β€” flush output stream after each output;
  • --stream β€” parse the input value in streaming fashion;
  • --stream-errors β€” implies --stream and report parse error as an array;
  • --seq β€” parse input/output as application/json-seq;
  • -f, --from-file file β€” load filter from the file;
  • -L directory β€” search modules from the directory;
  • --arg name value β€” set $name to the string value;
  • --argjson name value β€” set $name to the JSON value;
  • --slurpfile name file β€” set $name to an array of JSON values read from the file;
  • --rawfile name file β€” set $name to string contents of file;
  • --args β€” consume remaining arguments as positional string values;
  • --jsonargs β€” consume remaining arguments as positional JSON values;
  • -e, --exit-status β€” set exit status code based on the output;
  • -V, --version β€” show the version;
  • --build-configuration β€” show jq's build configuration;
  • -h, --help β€” show the help;
  • -- β€” terminates argument processing;

Named arguments are also available as $ARGS.named[], while positional arguments are available as $ARGS.positional[]. iykyk. ✨


πŸ‘‘ SEE ALSO πŸ‘‘

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

info xq

should give you access to the complete manual. go read her, she's thorough, she's gorgeous, she's a Texinfo girlie. πŸ’œ


and that's the whole page, bestie. this was xq 3.4.3, from May 2025, and yes that's the version and date right there in the footer β€” consider this my little sign-off, mwah, go transcode something. πŸ§šπŸ’–

πŸ“¦ where this page comes from