The .bib File: Open, Edit, Convert

A .bib file is a BibTeX file: a plain-text list of references that LaTeX and reference managers read. This page explains how to create, open, edit and convert one.

On this page
  1. What is a .bib file?
  2. How to create a .bib file
  3. How to open a .bib file
  4. How to edit a .bib file
  5. How to convert a .bib file
  6. Comments in a .bib file
  7. Related files

What is a .bib file?

A file with the extension .bib is a BibTeX bibliography database. It is a plain text file that holds one entry per reference: books, articles, websites and so on. LaTeX documents cite these entries by key, and BibTeX or biber turns the cited ones into a formatted reference list.

Property Value
File extension .bib
Content Plain text, no binary data or formatting
Encoding ASCII for classic BibTeX, UTF-8 for biblatex with biber
MIME type application/x-bibtex, also text/x-bibtex (neither is officially registered)
Read by BibTeX, biber, pandoc, and nearly every reference manager

A small .bib file with two entries:

@article{knuth1984,
  author  = {Knuth, Donald E.},
  title   = {Literate Programming},
  journal = {The Computer Journal},
  volume  = {27},
  number  = {2},
  pages   = {97--111},
  year    = {1984}
}

@book{lamport1994,
  author    = {Lamport, Leslie},
  title     = {{LaTeX}: A Document Preparation System},
  edition   = {Second},
  publisher = {Addison-Wesley},
  year      = {1994}
}

Each entry has a type (@article), a citation key (knuth1984) and a list of fields. The BibTeX Format describes all entry types, fields and syntax rules.

How to create a .bib file

  • By hand. Create a new file in any text editor, paste or type the entries and save it as references.bib. In Notepad, choose All files as the file type so it isn’t saved as references.bib.txt. In TextEdit on macOS, switch to plain text first (Format → Make Plain Text).
  • From a DOI or arXiv ID. The DOI → BibTeX converter returns a finished entry to copy into your file.
  • From Google Scholar. Click Cite under a search result, then BibTeX. Check the result: these entries are often incomplete.
  • From publisher and library sites. Most offer Export citation or Download citation with BibTeX as a format.
  • From a reference manager. Zotero, JabRef and Mendeley export a whole library or a selection as a .bib file. EndNote does it through its BibTeX Export output style.

How to open a .bib file

Because it is plain text, every text editor opens a .bib file: Notepad, TextEdit, Visual Studio Code, Vim, or a LaTeX editor such as TeXstudio. Double-clicking only works if a program has registered the extension. On Windows without such a program, you are asked which app to use; choose a text editor. On macOS with MacTeX installed, .bib files normally open in BibDesk.

To view the entries as a sortable, searchable table rather than as source text, open the file in a reference manager:

  • JabRef (Windows, macOS, Linux) opens .bib files directly, since BibTeX is its native format.
  • BibDesk (macOS) does the same.
  • Zotero and Mendeley import the entries into their own library (in Zotero: File → Import).
  • Overleaf shows and edits .bib files online, in the browser. Upload the file to a project.

How to edit a .bib file

Edit the text directly, or use JabRef or BibDesk, which offer a form for each entry and write valid syntax for you. When editing by hand, the usual mistakes are a missing comma between fields, unbalanced braces and a citation key that is used twice. bibtex-tidy reformats a file and finds duplicates.

If you manage your references in Zotero or Mendeley, change them there and export again, otherwise the next export overwrites your edits.

How to convert a .bib file

To a formatted reference list, plain text or PDF

With LaTeX, a short document that cites everything produces a PDF of the whole file:

\documentclass{article}
\begin{document}
\nocite{*}
\bibliographystyle{plain}
\bibliography{references}
\end{document}

Run pdflatex, bibtex, then pdflatex twice, see Using BibTeX. The bibliography style determines the format.

Without LaTeX, pandoc formats a .bib file directly:

pandoc references.bib --citeproc -t plain -o references.txt
pandoc references.bib --citeproc -o references.html

The default format is Chicago author-date. Add --csl=apa.csl with a style file from the Zotero style repository for APA or any other style.

To Word

Word’s own source manager (References → Manage Sources) cannot read .bib files. The options are:

  • Zotero or Mendeley. Import the .bib file, then cite from Word with the program’s Word plug-in.
  • JabRef. Export the entries (File → Export) in the MS Office 2007 format, an XML file, then load that file in Word under Manage Sources → Browse.
  • pandoc. pandoc references.bib --citeproc -o references.docx writes the formatted reference list as a Word document. Pandoc can also resolve citations in a Markdown manuscript and write the result as .docx.
  • BibTeX4Word. A set of Word macros for Windows that formats citations with BibTeX itself. It needs a MiKTeX installation.

To Excel or CSV

Open the .bib file in JabRef and choose File → Export with the format CSV, or import it into Zotero and choose File → Export Library with the format CSV. Excel and other spreadsheet programs open the result, with one row per entry and one column per field.

From RIS, EndNote or PubMed (nbib) to BibTeX

Zotero imports RIS (.ris), EndNote XML and PubMed’s .nbib files and exports them as BibTeX. JabRef imports RIS, EndNote and Medline/PubMed (.nbib) files into a .bib library as well. For RIS and EndNote XML, pandoc also works on the command line:

pandoc references.ris -t bibtex -o references.bib
pandoc -f endnotexml references.xml -t bibtex -o references.bib

For a single article, it is often quicker to paste its DOI into the converter.

Comments in a .bib file

BibTeX ignores all text that is outside an entry, so notes can be written between entries without any marker. There is also an explicit @comment{...} block. JabRef uses it to store its own settings in the file.

Entries below this line still need page numbers.

@comment{Checked against the library catalogue.}

@book{lamport1994,
  ...
}

The percent sign is not a comment character in BibTeX. A line starting with % between two fields of an entry produces an error, and the rest of the entry is skipped. Inside a field value, a % is passed on to LaTeX, where it comments out the rest of the line, so write \%. To disable a field, rename it instead, for example volume to OFF-volume: unknown fields are ignored. See @preamble and @comment for details.

  • .bst is a bibliography style: the program that tells BibTeX how to sort and format the entries.
  • .aux is written by LaTeX and lists the cited keys, the style and the .bib files for BibTeX.
  • .bbl is BibTeX’s output: the formatted reference list as LaTeX code, read by LaTeX on the next run.
  • .blg is BibTeX’s log file with its warnings and error messages.
  • .bcf is the control file that biblatex writes for biber, in place of the instructions in the .aux file.