XDelta explained

What Is XDelta? A Plain-English Guide to xdelta3 Patches

XDelta is the patch format behind countless fan translations, mods and software updates. This guide explains what it is, what’s inside a .xdelta file, and which tools can apply it, without assuming you’re a programmer.

  • Updated
  • Checked against Delta Patcher 3.1.6
  • 5 min read

In short

  • xdelta is an open-source tool by Joshua MacDonald for computing the differences between two files. xdelta3 is its current generation.
  • xdelta3 writes patches in VCDIFF, a standard binary patch format described in RFC 3284.
  • An XDelta patch holds instructions for rebuilding a file from an exact original, which makes it compact and well suited to large files.
  • Delta Patcher is a graphical app with xdelta3 built in, so you don’t need the command line.

XDelta in one paragraph

XDelta is a delta encoding tool. Give it two versions of a file and it produces a small file, the delta or patch, describing how to turn the first into the second. Anyone with the first file and the patch can rebuild the second, byte for byte. The name “XDelta” gets used for the program (xdelta, now xdelta3), the patch files it creates, and informally the whole approach. When people say “an XDelta patch,” they mean a patch made by or compatible with xdelta3.

xdelta, xdelta3 and VCDIFF

XDelta terminology
TermWhat it is
xdeltaThe original open-source differencing tool created by Joshua MacDonald. Older 1.x versions used their own patch format.
xdelta3The third-generation rewrite, and the version used today. It’s both a command-line program and a library other programs can build in.
VCDIFFThe standardized binary patch format xdelta3 reads and writes, published as RFC 3284. xdelta3 adds optional extensions such as secondary compression.
.xdelta fileA VCDIFF patch saved with the .xdelta extension. You’ll also see .vcdiff, .xdelta3 or .delta for the same format.
Delta PatcherA graphical app that embeds the xdelta3 library, so it can apply and create these patches without the command-line tool.

Every VCDIFF file starts with the same four bytes, D6 C3 C4 00: the letters “VCD” with the high bit set, followed by a version number. That signature is how xdelta3 recognizes a patch, and why it rejects other files with not a VCDIFF input.

What’s inside an XDelta patch

A patch doesn’t contain the new file. It contains a sequence of windows, and each window holds instructions for producing one chunk of the output:

The three VCDIFF instruction types
InstructionMeaningExample
COPYCopy a range of bytes, either from the source file or from output already produced.“Copy 4,096 bytes starting at byte 1,048,576 of the source.”
ADDInsert new bytes stored in the patch.“Add these 12 bytes of new text.”
RUNRepeat a single byte many times.“Write 2,048 zero bytes.”

Alongside the instructions, xdelta3 can store an Adler-32 checksum for each window, so it can confirm the output is correct as it goes, plus an optional application header. Delta Patcher uses that header to store its patch descriptions. A worked example of how patches rebuild a file.

Header signature, options, app data
Windows COPY · ADD · RUN instructions
Checksums Adler-32 per window
The main parts of a VCDIFF patch produced by xdelta3.

Why XDelta is popular for large files

  • It handles inserted and moved data. COPY instructions can reference any position in the source, so data that shifted still becomes a cheap copy. Simpler formats like IPS can only overwrite bytes at fixed positions.
  • It scales to big files. xdelta3 streams through files window by window, so multi-gigabyte disc images work. Delta Patcher supports files over 4 GB since version 3.1.5.
  • It catches wrong source files. Per-window checksums stop the patch instead of producing a silently broken file.
  • It compresses well. New data can be compressed, with secondary compressors like LZMA for extra savings.
  • It’s open and cross-platform. The format is a published standard and the tools are open source.

The trade-off is strictness: an XDelta patch works only with the exact source file it was created from. How XDelta compares with IPS, UPS, BPS and PPF.

Tools that apply and create XDelta patches

Delta Patcher vs the xdelta3 command line

Choosing between Delta Patcher and xdelta3
Delta Patcherxdelta3 command line
InterfaceGraphical window with drag and dropTerminal commands
Apply patchesYesYes
Create patchesYesYes
Choose output name and locationNo. Saved next to the original, replacing it unless backup is onYes, any path
Patch descriptionsWrites and displays them (Patch info tooltip)Can write raw application data; doesn’t display Delta Patcher descriptions
Compression and window optionsLevel 0–9, secondary compression, source window size, checksumAll of those, plus many advanced tuning flags
Scripting and batch jobsNoYes
InstallationPortable app for Windows, macOS, LinuxSeparate binary; availability varies by platform

For applying a patch someone gave you, Delta Patcher is simpler and harder to get wrong. For automation, or when you need to choose the output file name, use xdelta3.

Basic xdelta3 commands

If you do use the command line, these are the two commands you need. Quote paths containing spaces.

Apply a patch (decode)
xdelta3 -d -s original.bin patch.xdelta patched.bin
Create a patch (encode)
xdelta3 -e -s original.bin modified.bin patch.xdelta
Common xdelta3 options
FlagMeaning
-dDecode: apply a patch.
-eEncode: create a patch.
-s fileThe source (original) file.
-fOverwrite the output file if it already exists.
-nDon’t write or verify checksums. Avoid this.
-0-9Compression level when encoding.
-S lzma|djw|fgk|noneSecondary compressor when encoding.
-B bytesSource window (buffer) size.

Delta Patcher runs the same engine with the same options: applying passes -d, -f and -s, and turning off checksum validation adds -n.

Limitations to know about

  • Exact source required. A different revision, region or dump won’t work. Why checksums fail.
  • One file per patch. A patch maps one source file to one target file, so projects that change several files need several patches or a single container file.
  • Compressed or encrypted data patches poorly. A small change can alter everything after it, which inflates patch size.
  • Mixed tool support for extensions. Secondary compressors and application headers aren’t supported by every third-party patcher.

Continue learning

Sources and references