#cli #json #toml #xml #yaml

bin+lib convert2json

CLI utilities to convert CSV, TOML, XML & YAML into JSON and for use with jq

13 releases (4 breaking)

0.5.0 Sep 18, 2023
0.4.8 Sep 10, 2023
0.4.7 Aug 28, 2023
0.4.4 Jul 31, 2023
0.1.0 Jun 25, 2023

#717 in Encoding

Download history 18/week @ 2023-06-21 91/week @ 2023-06-28 35/week @ 2023-07-05 12/week @ 2023-07-12 24/week @ 2023-07-19 52/week @ 2023-07-26 9/week @ 2023-08-02 39/week @ 2023-08-09 13/week @ 2023-08-16 29/week @ 2023-08-23 14/week @ 2023-08-30 22/week @ 2023-09-06 25/week @ 2023-09-13 17/week @ 2023-09-20

93 downloads per month

MIT license

390 lines


Utilities for use on the command line, to convert CSV, TOML, XML & YAML to JSON. For each supported format there is a tool for use in a pipe as well as a jq wrapper which passes the converted input or files in the arguments to jq, for further querying and processing.

Usage examples:

$ echo foo: bar | yaml2json
$ tq -r .package.description Cargo.toml
CLI utilities to convert CSV, TOML, XML & YAML into JSON on standard output or into jq.



  • provide light-weight converters to JSON
  • provide jq wrappers
  • add support for additional formats having maintained Serde implementations


  • converting JSON into other data formats, consider jyt
  • replicating jq, jq must be installed to use the jq wrappers


To Do:

  • in jq arguments, ignore filenames if preceeded by certain flags (i.e. --from-file)


Packages are provided (statically linked) for Debian & Ubuntu, as wells as RPM based Linux distributions and for Alpine Linux.

For Ubuntu, MacOS (universal binaries for x86_64 & arm64) and Windows, archives with pre-built (dynamically linked) binaries are provided, for manual installation.

You can find these packages and archives in the releases.

If you have Rust and Cargo installed, you can build and update these tools using cargo install convert2json. See the feature matrix below, if you only need a subset of the utilities.

Feature Matrix

You may not want to install all of the utilities or only a particular one. Each utility can be selected by itself or via group features. If no features are selected, all utilities get installed.

Matrix of all selectable features:

to_json jq
csv csv2json cq
toml toml2json tq
xml xml2json xq
yaml yaml2json yq


cargo install convert2json --no-default-features --features yq,tq
cargo install convert2json --no-default-features --features xml


~184K SLoC