Extract and apply patches to JSON documents.

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed by Thomas Sutton

Aeson Diff

Build Status Hackage Hackage-Deps

This is a small library for working with changes to JSON documents. It includes a library and two executables in the style of diff(1) and patch(1). Patches are themselves JSON Patch documents as specified in RFC 6902.


The aeson-diff package is written in Haskell and can be installed using the Cabal package management tool, stack, or something similar.

bash stack install aeson-diff

The command-line tools can then be executed using stack:

stack exec json-diff -- .... stack exec json-patch -- ....

If you prefer to use Cabal, something like this might do the trick:

bash cd aeson-diff/ cabal sandbox init cabal install --dependencies-only cabal build sudo mkdir -p /usr/local/bin sudo cp dist/build/json-*/json-{diff,patch} /usr/local/bin/


Patch format

aeson-diff supports the JSON Patch format described in RFC 6902.

json-diff command

The json-diff command compares two JSON documents and extracts a patch describing the differences between the first document and the second.

Usage: json-diff [-T|--test-before-remove] [-o|--output OUTPUT] FROM TO Generate a patch between two JSON documents.

Available options: -h,--help Show this help text -T,--test-before-remove Include a test before each remove. -o,--output OUTPUT Write patch to file OUTPUT.

json-patch command

The json-patch command applies a patch describing changes to be made to a JSON document.

Usage: json-patch [-o|--output OUTPUT] PATCH FROM Generate a patch between two JSON documents.

Available options: -h,--help Show this help text -o,--output OUTPUT Destination for patched JSON. PATCH Patch to apply. FROM JSON file to patch.

aeson-diff library

The aeson-diff library exports as single module: Data.Aeson.Diff. This exports diff and patch functions which do exactly what might be expected:

  • diff :: Value -> Value -> Patch examines source and target JSON Values and constructs a new Patch describing the changes.

  • patch :: Patch -> Value -> Value applies the changes in a Patch to a JSON Value. If an error results then an exception is thrown.

For more complete information, see the documentation.



* aeson-diff can now, optionally, generate a test operation before each

* Add '--test-before-remove' option to 'json-diff' command.

* Add 'Config' type and 'diff'' to allow optional behaviours.


* Remove the `patch'` function before anyone gets attached to it.

* Remove the 'Value' which was carried by the 'Rem' operation constructor.

* Move 'Pointer' and 'Patch' types and operations into separate modules.

aeson-diff 1.0

* aeson-diff now supports the operations and patch format described in
  RFC 6902.

* The `patch` function now returns in the 'Result' monad from the aeson

* Add a `patch'` function throws an exception instead.

* The command line applications no longer pretend to support a non-JSON
  patch format.

aeson-diff 0.1

* Initial release.
comments powered byDisqus