Bib(la)tex parsing and useful tools

bibpy, bibtex, biblatex, parser, bibformat, bibgrep, bibstats, python
pip install bibpy==1.0.0


bibpy v0.1.0

Build status GitHub license

Python library for parsing bib(la)tex files and manipulating entries.

Take a look at the quickstart example for basic usage, or the more complete tutorial.


Use pip:

pip install bibpy

Or git clone and then run python install from the bibpy directory.


import bibpy
import re

# Read a bib file
entries, strings, preambles, comment_entries, comments =\

# Print number of entries
print len(entries)
# Print the author of the first entry
print entries[0].author
# Print all entries after year 2010
print [entry for entry in entries if entry.year > 2010]
# Print all unique authors
print set([ for entry in entries])
# Print all entries where the key contains 'david'
print [entry for entry in entries
       if'david', entry.key, re.I)]
# Check that the first entry has the correct
# fields for its type according to biblatex
print entries[0].valid('biblatex')
# For example 'article' or 'inproceedings'
print entries[0].entry_type
# Print the available aliases for this entry's type
print entries[0].aliases('bibtex')

# Write out the entries to "references.bib" as biblatex.
bibpy.write_file("references.bib", entries, 'biblatex')

See the examples folder for more usage examples or read the tutorial.


bibpy also comes with three tools in the bin folder that are installed as runnable scripts.

  • bibformat: Clean up, format and align references
  • bibgrep : Find and filter references using a simple query language
  • bibstats : Display statistics about bib files

All three tools are described in more detail in the tutorial.