#cli #serde #messagepack

bin+lib xt

Translate between serialized data formats

21 releases (11 breaking)

0.19.0 Feb 5, 2024
0.18.3 Dec 24, 2023
0.18.2 Aug 1, 2023
0.18.1 Jul 24, 2023
0.10.0 Jun 13, 2022

#330 in Command line utilities

Download history 16/week @ 2023-10-26 10/week @ 2023-11-02 7/week @ 2023-11-09 27/week @ 2023-11-16 33/week @ 2023-11-23 30/week @ 2023-11-30 6/week @ 2023-12-07 24/week @ 2023-12-14 83/week @ 2023-12-21 3/week @ 2023-12-28 25/week @ 2024-01-04 1/week @ 2024-01-11 6/week @ 2024-01-18 25/week @ 2024-01-25 53/week @ 2024-02-01 53/week @ 2024-02-08

137 downloads per month

MIT license



xt is a cross-format translator for JSON, YAML, TOML, and MessagePack.

For example, you can process a set of TOML files with jq:

$ xt a/Cargo.lock b/Cargo.lock | jq -r '.package[].name' | sort -u
# etc.

Or transform a JSON configuration file into YAML for easier editing:

$ xt -t yaml config.json > config.yaml

Or store an unbounded stream of JSON events as MessagePack to save space:

$ curl localhost:8001/apis/events.k8s.io/v1/events?watch | xt -tm > events.msgpack


xt is built with Rust, and leverages the powerful Serde ecosystem of data serialization and deserialization libraries.

After installing Rust on your system, you can install xt from crates.io using Cargo:

cargo install --locked xt


On NetBSD a pre-compiled binary is available from the official repositories. To install it, simply run:

pkgin install xt-rs

Usage and Features

xt [-f format] [-t format] [file ...]

Or, run xt --help for full usage information.

xt is built to "do one thing well," and tries to maintain a minimal interface and feature set. The most common options are -t to specify an output format other than JSON, and one or more files to read from rather than standard input.

Some of xt's notable features include:

Automatic Format Detection

When the input format is not specified with the -f option, xt can detect it automatically by file extension, or by examining the content of the input stream itself.

Multi-Document Support

With most output formats, xt can translate multiple input files, each containing one or more independent documents, to a single output stream. For example, a set of YAML files with documents separated by --- markers can translate to a single stream of newline-delimited JSON objects. With format detection enabled, xt can even translate input files in different formats to a single output.

Streaming Translation

xt can translate multi-document inputs from unbounded sources like shell pipes with minimal buffering, while still supporting features like automatic format detection. Streaming is enabled automatically whenever it's required.


xt is released under the terms of the MIT License. See LICENSE.txt for more information.


~67K SLoC