select values out of nested JSON, YAML and XML documents

One selector instead of a throwaway script

Every configuration format ends up nested, and every nested format ends up needing a one-off script to get a value back out of it. treesift is a single small command that reads JSON, YAML or XML and prints the parts you asked for.

$ echo '{"services":{"web":{"ports":[8080,8443]}}}' | treesift -c 'services.web.ports[0]'
8080

The same selector syntax works across all three formats, so a pipeline does not have to care whether today's input arrived as YAML from a deployment manifest or as XML from some older service.

Install

treesift is one Python file with no required dependencies. Python 3.8 or newer is enough; YAML input additionally needs PyYAML.

curl -O https://treesift.xyz/dl/treesift-0.4.2.tar.gz
tar xzf treesift-0.4.2.tar.gz
cd treesift-0.4.2
sudo install -m 0755 treesift /usr/local/bin/treesift

Current release is 0.4.2 (14 July 2026) — treesift-0.4.2.tar.gz, sha256. MIT licensed.

Selectors in one table

SyntaxMeaning
a.bkey b inside object a
a[2]third element of list a
a[]every element of list a
a.*every value of object a

Steps compose. services.*.ports[] walks every service and flattens all of their port lists into a single stream of results.

Why not jq

jq is a better tool and a bigger one. It is a language, and languages are worth learning when the work justifies it. treesift covers the narrow case that comes up constantly — reach into a document, pull out a value, move on — and covers it the same way for three formats instead of one. If a selector is not enough for what you are doing, that is the point at which jq earns its keep.

Status

treesift is small on purpose and close to finished. Selector syntax has been stable since 0.3.0 and is not expected to change before 1.0. Releases are occasional and mostly consist of format-sniffing fixes against documents found in the wild.