TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was constructing a BibTeX file for my Thesis. At the middle of that I had copied that bib file to another document I had to produce, I had to add some new citations to the copy of the original.

Now I have 2 bib files that have a lot in common but differ in some citations. Is there a way to merge them? So that I have one single file with all the citations from both files but no duplicates?

share|improve this question
This is a duplicate question. (I don't know how to mark it) And I have solved the problem with BibDesk for Mac OS. – Tiago Veloso Jun 6 '11 at 10:37
This question is not related to TeX. There are a lot of programs that can merge text files. In Linux you can try with Kdiff3 or meld. In Windows WinMerge is fine. The merge process might be automatic (if you just appended the citations), but it will propably need some manual handling (especially if you changed the data on some refs). – pmav99 Jun 6 '11 at 10:38
@pmav99 I think the TeX in BibTeX is enough to warrant a place here. Also WinMerge, Kdiff and all diff like tools work on a line-by-line basis, whereas BibTeX files work on entries and not lines. – Tiago Veloso Jun 6 '11 at 10:41
up vote 35 down vote accepted

bibtool -s bibliography1.bib bibliography2.bib will merge two bib files, keeping duplicate entries. bibtool -s -d bibliography1.bib bibliography2.bib will merge two bib files, commenting out one of the duplicated entries (not sure which one). For more info, see documentation.

Bibtool is on CTAN. Not to be confused with bibtools which is also on CTAN and probably also has the capacity to do this sort of thing...

Bibtool can also be found in Ubuntu repositories. (I wasn't able to compile the one from CTAN)

share|improve this answer

JabRef is a bibliography manager that has tools for merging bib-files. Or rather, for importing one file into another: File --> Import into current database. Not sure if it checks for duplicates on merge, but there is a tool for checking for duplicates as well: Tools --> Scan database --> Find duplicates.

share|improve this answer
+1 for JabRef :-) – Tobi Jun 6 '11 at 14:46
+2 for Jabref. I normally don't fall for GUI programs. But Jabref did the merging quite well. Whats more, it arranged the new database alphabetically, something I had been wanting to do for a while. – cryptic0 Mar 26 '13 at 20:23
One can select "Deselect all duplicates" right before merging the two databases and thus obtain a set of unique references. – Marius Hofert Mar 24 at 13:32

I think there is no easy way to do this. Though it is possible to write a perl script alike to use regex to do this. But the problem is

  1. Sometimes two entries are duplicates though they are not exactly the same, for example different capitalization in titles or extra {and }. So we have to workaround this by define some threshold for difference.

  2. Sometimes two entries from the same author of the same year with a little difference in the title are indeed two papers. This make the threshold in (1) hard to define.

So I suggest you can only do this by hand. A relative easier way is do it with a BibTeX editor, for example BibDesk on Mac OS X. Import both files into it, and it shall warn you when two entries have the same citekey. So for those entries with same citekeys, which are almost surely duplicates, you can clean them up easily. If I remember correctly BibDesk and other editors do have this functionality. After this, sort all entries by title, and spot further duplicates by your eyes.

share|improve this answer
I had BibDesk, but I did not know of this feature. Sure made my life easier. – Tiago Veloso Jun 6 '11 at 10:44
I think it is a shame that this is the accepted answer given that there are two good ways to do this suggested in the other answers. – Seamus Jun 13 '13 at 20:56

Just to re-ensure Torbjorn's point, JabRef checks for duplicates when using File -->Import into current database. D indicating duplicate entries in current bib database

Entries marked with "D" are duplicates found by JabRef 2.10. You can then use "Deselect All Duplicate" button to get rid of the duplicates.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.