merge3
Python implementation of 3-way merge
What it is and what it does
merge3 is a pure-Python implementation of the 3-way merge algorithm used in version control systems. It takes three text sequences—a common base and two independent modifications—and produces a merged result that incorporates both changes. When changes conflict, it marks the conflicting regions with annotated conflict markers so you can see which branch contributed which lines.
The package works with sequences of lines (typically strings) rather than raw files, giving you control over how to split and process text. It can be used as a library from Python code or invoked as a command-line tool. With no external dependencies and support for modern Python versions, it's lightweight and straightforward to integrate into tools that need to resolve text merges programmatically.
Use it for:
- Implement merge logic in a custom version control or document collaboration tool
- Resolve text conflicts when merging branches in a non-Git workflow
- Build a three-way diff viewer that shows how changes from two sources combine
- Automate merging of configuration or data files from multiple sources
- Test merge behavior in applications that handle concurrent text edits
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements 3-way merge of text sequences, combining changes from two independent branches against a common base to produce a merged result with conflict markers.
Yes, if you need 3-way merge logic and accept the GPL-2.0-or-later copyleft constraint. The package is actively maintained, has no dependencies, and works across modern Python versions. It's a solid choice for tools that must resolve text conflicts programmatically. No if your project cannot adopt copyleft licensing.
Install
merge3 on PyPI
pip
pip install merge3uv
uv add merge3poetry
poetry add merge3Installing merge3
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and broad Python version support from 3.9 through 3.14.
License in practice
GPL-2.0-or-later copyleft license: any derivative work or distribution must be released under compatible terms. Review your project's licensing model before integrating.
Quickstart
import merge3
m3 = merge3.Merge3(
['common\n', 'base\n'],
['common\n', 'a\n'],
['common\n', 'b\n']
)
result = list(m3.merge_annotated())
Requires Python 3.9 or later.
Verify before relying
- Whether conflict markers are customizable or follow a fixed format
- Performance characteristics on large text sequences or files
- Whether the package handles binary data or is text-only
Package facts
| License | GPL-2.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 303 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 90,017/month — #13,621 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: merge3-0.0.16-py3-none-any.whl
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
deepmergeMerges nested Python data structures (dicts,…
permissive · top 5,000 on PyPI
mergedeepMerges nested dictionaries recursively,…
permissive · top 1,000 on PyPI
textdistanceComputes distance and similarity between text…
permissive · top 5,000 on PyPI
fastdiffFastdiff provides a fast diff algorithm…
permissive · top 15,000 on PyPI
ansimarkupAnsimarkup converts XML-like markup tags into…
permissive · top 15,000 on PyPI
jsonmergeMerges multiple JSON documents into a single…
permissive · top 5,000 on PyPI
pytest-html-mergerMerges multiple pytest HTML reports generated…
unclear · top 15,000 on PyPI
diff-match-patchProvides diff, match, and patch algorithms for…
permissive · top 5,000 on PyPI
django-linear-migrationsEnforces linear migration history in Django…
permissive · top 5,000 on PyPI