Removing URLs from Zotero bibtex exports

When you export bibtex from zotero, it includes the URLs in the bibtex records. Some LaTeX bibliography styles include this information, and sometimes this is not what you want, for example because the URLs take up unnecessary space and are hard to wrap.

It’s quite easy to get zotero to export bibtex without the URLs.

  1. Go to Preferences | Advanced and click on the “Show Data Directory” button.
  2. Edit translators/BibTeX.js with your favourite text editor.
  3. In function doExport(), at around line 2040 in Zotero 3.0.7, change the “for (var field in fieldMap)” loop by adding a single line of code like this:
for(var field in fieldMap) {
    # only add the following line:
    if (field == "url") continue;
    if(item[fieldMap[field]]) {
        writeField(field, item[fieldMap[field]]);

If your changes don’t seem to take, make sure that your text editor did not make a backup of the old BibTeX.js (vim does this, with an ~ appended), as Zotero could possible pick up the backed up version instead of your edited version.

Let me know in the comments if this helped!

Look! References without URLs!

Update on 2013-02-17: Added tip concerning editor backups of BibTeX.js (I ran into this problem myself).

13 thoughts on “Removing URLs from Zotero bibtex exports”

  1. Cool, but why does this method not work to eliminate the entries ‘urldate’ and ‘file’ in a similar way? Is there another way?
    thanks in advance.

  2. Thanks, you may also want to avoid exporting the “file” category which only applies if you keep your PDFs in Zotero – this is also a long string which doesn’t wrap in TeXstudio. To remove this field, just comment out (“//” before the line) this line which is a few lines down from the url section:
    writeField(“file”, attachmentString.substr(1));

  3. Thank you for the post! It helped me a lot!!! However, the directory translators/BibTeX.js was a little bit different in my case: zotero/translators/BibTeX.js

    Also, doExport() function do not have the code presented and I had to look directly for “var field in fieldMap” to add the line suggested.

  4. Great tip, thanks this saves me a huge headache. Some additional changes I made were to also prevent “abstract” from writing with `if (field == “abstract”) continue;` jsut after your suggested line and commenting out the line `writeField(“file”, attachmentString.substr(1));` as you suggested in the comments. Thanks again. AM.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.