An improved diff3 format using XML: diff3x

Robin La Fontaine


Nigel Whitaker



There is no doubt that the diff and diff3 format has established itself as a well-used de-facto standard. It might seem presumptuous to suggest that it could be improved, or indeed that it needs to be improved. However, the original premise of line-based text files as the subject matter is now out of date with more structured information being the norm. Often this is in the form of programming source code where the layout tends to remain fairly consistent through edit cycles, but increasing use of JSON and XML pose particular difficulties for the simple line-based structure of diff3.

In our paper at MarkupUK in 2019, we discussed some of the issues and suggested some minor improvements to diff3. These changes suffered from the common complaints of a retro-fit in that they did not sit comfortably with the original and only did half a job. The prevalence of GUIs also suggest that the actual syntax of a diff file is not as important as it was in that the emphasis has changed from human readability to interchange between two applications, for example between a git 'merge driver' and a git 'mergetool'. For these reasons it seemed better to consider a different approach using the tools and formats that are now in common use, for example XML or JSON.

What might diff3 look like as an XML format? Would the advantages of a new format make it worth swapping from the tried and tested diff3? Could existing GUI software easily adapt to a new format and, perhaps, even be simpler as a result?

Table of Contents

Introduction and Background
Developing an XML syntax for diff3x
Showing Non-conflicting Changes
Showing linked changes to JSON Structure in diff3x
Representing JSON Separator Change in diff3x
Preserving well-formed tree structure in diff3x
Representing XML Element Tag Change in diff3x
Representing XML Attribute Change in diff3x
Nested Changes
Should an XML Payload be represented as XML or text?
Saving Selected Options
Comparing diff3 format with diff3x
Future work