xq - Man Page

command-line XML and HTML beautifier and content extractor


xq [options...] [file]


Formats the provided file and outputs it in the colorful mode. The file can be provided as an argument or via stdin.


--version | -v

Prints versions information and exits.

--help | -h

Prints the synopsis and a list of options and exits.

--indent int

Uses the given number of spaces for indentation (default 2).


Disables colorful output (only formatting).


Uses tabs instead of spaces for indentation.

--xpath | -x string

Extracts the node(s) from XML using provided XPath query.

--extract | -e string

Extracts a single node from XML using provided XPath query.

--query | -q string

Extract the node(s) using CSS selector.

--html | -m

Uses HTML formatter instead of XML.


Format an XML file and highlight the syntax:

$ xq test/data/xml/unformatted.xml

Utility also accepts input through stdin:

HTML content can be formatted and highlighted using -m flag:

$ xq -m test/data/html/formatted.html

Extract the text content of all nodes with city name:

$ cat test/data/xml/unformatted.xml | xq -x //city

See Also

https://github.com/sibprogrammer/xq - official website


06 Nov 2022 xq man page