Jeromy Anglim's Blog: Psychology and Statistics

Monday, March 15, 2010

Export from Endnote to BibTeX, JabRef, and LaTeX

This post sets out a procedure that I used to migrate a large set of Endnote references in a Word Document to a Latex document with BibTeX references in JabRef. In particular, it sets out (1) how to export an Endnote database into BibTeX format ready for inclusion in a LaTeX document; and (2) how to modify an existing document with Endnote citations into a document that cites the BibTeX database.

Exporting Endnote database into BibTeX format

Josh explains how to do this using JabRef. However, if you want to alter a document with a large number of existing Endnote citations, you may want to adopt a modified procedure. Below I set out the procedure that I adopted. However, I don't claim it to be the most elegant procedure. Nonetheless, it may give you some ideas.

Changing Endnote Citations to BibTeX format

If you already have a document with Endnote citations, you are going to need to convert these citations to BibTeX format. If the document only includes a few citations, this conversion can be done manually with little effort. However, if you have a book or thesis with several hundred citations, you may want a quicker and more reliable method. The remainder of this post sets out a procedure that I adopted to transition my own Word document with around 500 unformatted Endnote citations to BibTeX format.

This post assumes that:
  • you have exported your document from a word processor into some preliminary LaTeX format.
  • you have unformatted Endnote citations in the document
  • you have JabRef installed
  • you have some understanding of how Endnote, LaTeX, JabTeX, and BibTeX work.


An unformatted Endnote citation typically looks like this:
  • Single Author and Year: {Author, Year #Record Number} : e.g., {Anglim, 2008, #231}
  • Multiple Author and Year: {Author, Year #Record Number; Author, Year #Record Number} : e.g., {Anglim, 2008, #231; Smith, 2009, #100}
  • Just Year: {, Year #Record Number} : e.g., {, 2008, #231}
  • Author and Year with preceding text: {introductory text \Author, Year #Record Number} : e.g., {see \Anglim, 2008, #231}
  • Author and Year with following text: {Author, Year #Record Number, following text} : e.g.,  {Anglim, 2008, #231, p.73}
The key in the Endnote database is called a record number. A BibTeX key is a text string which it is typically some automatically generated function of the record such as AuthorYear (e.g., "Anglim2008"). The first step to any updating procedure is to ensure that there is database that matches the Endnote key with the BibTeX key.

Importing Endnote Record Numbers into JabRef

Step 1.

Read Josh's protocol but don't follow it just yet. The problem with this procedure is that it does not export the Record Number.

Step 2.

Instead of following Josh's protocol exactly, the following modifies the protocol to include exporting of the Endnote Record Number. Create a copy of "BibTeX Export to JabRef.ens" and name it "BibTeX Export to JabRef RecordNumbers.ens"

Step 3.

Modify the output style:
  1. In Endnote go into edit this style "BibTeX Export to JabRef RecordNumbers.ens".
  2. Go to bibliography templates.
  3. For each Reference Type (e.g., Journal, Book, etc.) add an extra line with the following text:`endnotekey = {`Record Number`},`
  4. Paste the above text just after the "URL" line is one option. E.g., it might look something like this in the area around the pasting:
       `Abstract = {`Abstract`},`
       `Note = {`Notes`},`
       `URL = {`URL`},`
       `endnotekey = {`Record Number`},`
       `EndNoteRefType = {Journal Article},`

Step 4.

Return to Josh's protocol but use "BibTeX Export to JabRef RecordNumbers.ens" to export from Endnote. I.e.,
  1. Highlight all rows of your Endnote Database and Export the references
  2. Use "BibTeX Export to JabRef RecordNumbers.ens" and File Export
  3. after exporting change the file extension of the exported file to ".bib".
  4. open the bib file in JabRef

Step 5.

After opening the BibTeX file in JabRef, add "endnotekey" as a field:
  1. Menu: Options - Set General Fields
  2. Add the following to the end of the line that starts with "General: " ";endnotekey"

Step 6.

To enable you to see the Endnote Record Number in the main viewing table in JabRef:
  1. Options - Preferences Menu
  2. Entry table columns
  3. Add (Plus)
  4. add the field "endnotekey"

Step 7.

Auto-generate a BibTeX key for all the imported references. In a previous post I discuss some of the issues regarding choosing a BibTeX auto-generation key.

Manually Update Endnote Citations

At this point each unformatted endnote reference could be manually updated so that it refers to the appropriate BibTeX key. E.g., If you had an unformatted Endnote citation with Endnote Record Number like: {Bryan, 1897 #1366}, you could do the following:
  1. Search for this record number in JabRef
    1. Control + F (to open Search in JabRef)
    2. "endnotekey=1366" (to get the specific article) OR simply "1366" (this may not always be unique but saves a little typing)
  2. Copy the BibTexKey: Control + K would copy to the clipboard: \cite{Bryan1897}.
  3. Paste over the unformatted Endnote citation in your LaTeX document.

Automatically Update Endnote Citations to BibTeX format

A more advanced alternatively involves automatically replacing [endnotekey] with [bibtexkey] throughout the LaTeX document. There are many ways that this could be done. The following is a fairly inelegant method using a combination of Excel and Word (see the bottom of this post for alternatives). The post assumes that the hash symbol (#) followed by a number only occur in relation to Endnote citations.

1. Create a copy of your ".bib" file

  1. call it "copy.bib"

2. Copy the "endnotekey" field into the "note" field.

This is required because the "endnotekey" field is not included in a standard export.
  1. Open "copy.bib"
  2. Tools - Set/Clear/Rename Fields
  3. Field name: "endnotekey" and Rename field to "note"
  4. OK

3. Export the JabRef Database to a Spreadsheet readable format.

  1. File - Export
  2. File of type: "OpenOffice CSV (*.csv); let's call it "bib.csv"

4. Open "bib.csv" in Excel

The following steps would presumably work in most other spreadsheet programs like Open Office, perhaps with some modification to the function.

5. Create in Excel the code required for the VBA Word Procedure

The general format of the procedure is:
ReplaceEndnoteRef EndnoteKey, BibtexKey
where ReplaceEndnoteRef is the name of the procedure, EndnoteKey is the number of the endnote key, and BibtexKey is the BibtexKey. For example, this could be:
ReplaceEndnoteRef 724, "Smith2008"
  1. To create this in your spreadsheet (with bib.csv) enter the following function in an extra column (it assumes that the "note" field is in column M and the bibtex identifier is in column C):
  2. ="ReplaceEndnoteRef "&M2&", "&CHAR(34)&C2&CHAR(34)
    This should result in one cell that looks something like this:
    ReplaceEndnoteRef 1294, "Abraham1992AoDPS"
  3. Copy and paste the function so that it applies to all rows.
  4. Sort all rows by the "note" field in descending order. The code needs to be run in this order to avoid inappropriate replacements.
  5. Paste a copy of the LaTeX text into a New Word Document. WARNING: do not run this macro on your document without a backup.
  6. Apply a macro in Word
    1. Paste your latex text into a new word document
    2. Open up the Visual Basic Editor and paste the function below (insert a new module if needed)
      Sub ReplaceEndnoteRef(EndnoteKey, BibtexKey)
          EndnoteKey = "#" & EndnoteKey
          With Selection.Find
              .Text = EndnoteKey
              .Replacement.Text = BibtexKey
              .Forward = True
              .Wrap = wdFindContinue
              .Format = False
              .MatchCase = False
              .MatchWholeWord = False
              .MatchWildcards = False
              .MatchSoundsLike = False
              .MatchAllWordForms = False
          End With
          Selection.Find.Execute Replace:=wdReplaceAll
      End Sub
    3. Create a new procedure and paste the commands from Excel. Here are the first few lines of such a procedure
      Sub ReplaceRefs()
      ReplaceEndnoteRef 1495, "Sternberg1979AP"
      ReplaceEndnoteRef 1494, "Thoresen2004JoAP"
      ReplaceEndnoteRef 1493, "Lievens2002MEa"
      ReplaceEndnoteRef 1492, "Lievens2002ME"
      ReplaceEndnoteRef 1491, "Goldberg2006JoRiP"
      ReplaceEndnoteRef 1490, "Carroll1865"
      ReplaceEndnoteRef 1489, "Walsh2009CP"
      ReplaceEndnoteRef 1488, "Zimbardo1973NYTM"
      ReplaceEndnoteRef 1487, "Anglim2000"
      ReplaceEndnoteRef 1486, "Fry"
      ReplaceEndnoteRef 1485, "Anglim2007"
      ReplaceEndnoteRef 1484, "Zou2007PM"
      ' And many more references
      end sub
    4. run the ReplaceRefs() procedure on your document. F5 is a shortcut key when the cursor is in the procedure. This should automatically replace endnotekeys with bibtexkeys.

      This still leaves a fair amount of text in the citation to tidy up, but it is at least a reasonable start. In addition the remaining text is likely to be relevant to how the text should appear (i.e., whether there is preceding text, or following text, and whether the authors names should appear).

      If you continue to use this version of the database you may want to clear the "note" field so that the endnote key is no longer present. Otherwise it may appear in references. This can be done using the Tools - Set/Clear/Rename Fields menu option in JabRef.


After devising the above procedure, I discovered Noah Hoffman's Approach involving Python Scripts. It might also be worth a look.


  1. Very well done! Somehow I'm sure I'll end up having to refer to this at some point. I would also recommend this post as a substitute for my method of exporting. I think his is a little more straight forward and I'm guessing would fit nicely with Jeromy's procedure.


  2. Thanks for your post and the extra resource.

  3. Hi all;
    Does this procedure work with Endnote X5?


  4. There are a couple of online tools now. This one is fairly simple to use: