https://github.com/trailofbits/graphtage

Graphtage

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/54cf5079-f1e4-451e-a9fd-e3add9ac947e/68747470733a2f2f62616467652e667572792e696f2f70792f6772617068746167652e737667

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e845cbc9-9476-4922-a5fe-4badaf5e4133/badge.svg

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/42e02660-e9a8-4378-89ee-cce5d4d6ded6/68747470733a2f2f656d70697265736c61636b696e672e6865726f6b756170702e636f6d2f62616467652e737667

Graphtage is a commandline utility and underlying library for semantically comparing and merging tree-like structures, such as JSON, XML, HTML, YAML, plist, and CSS files. Its name is a portmanteau of “graph” and “graftage”—the latter being the horticultural practice of joining two trees together such that they grow as one.

Graphtage Example

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/71b73f9d-0f3b-4758-904c-b514ffa59f7d/example.png

Installation

$ pip3 install graphtage

Command Line Usage

Output Formatting

Graphtage performs is analysis on an intermediate representation of the trees that is divorced from the filetypes of the input files. This means, for example, that you can diff a JSON file against a YAML file. Also, the output format can be different from the input format(s). By default, Graphtage will format the output diff in the same file format as the first input file. But one could, for example, diff two JSON files and format the output in YAML. There are several command line arguments to specify these transformations; please check the --help output for more information.

By default, Graphtage pretty-prints its output with as many line breaks and indents as possible.

{
 "foo": [
 1,
 2,
 3
 ],
 "bar": "baz"
}

Use the --join-lists or -jl option to suppress linebreaks after list items:

{
 "foo": [1, 2, 3],
 "bar": "baz"
}

Likewise, use the --join-dict-items or -jd option to suppress linebreaks after key/value pairs in a dict:

{"foo": [
 1,
 2,
 3
], "bar": "baz"}