Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

python-bibtexparser v2

Welcome to python-bibtexparser, a parser for .bib files with a long history and wide adaption.

Bibtexparser is available in two versions: V1 and V2. For new projects, we recommend using v2 which, in the long run, will provide an overall more robust and faster experience. For now, however, note that v2 is an early beta, and does not contain all features of v1. Install v2 using pip:

pip install bibtexparser --pre

Or you can install the latest development version directly from the main branch:

pip install --no-cache-dir --force-reinstall git+https://github.com/sciunto-org/python-bibtexparser@main

If instead, you want to use v1, install it using:

pip install bibtexparser~=1.0

Note that all development and maintenance effort is focussed on v2. Small PRs for v1 are still accepted, but only as long as they are backwards compatible and don't introduce much additional technical debt. Development of version one happens on the dedicated v1 branch.

The remainder of this README is specific to v2.

Documentation

Go check out our documentation on https://bibtexparser.readthedocs.io/en/main/.

Advantages of V2

  • 🚀 Order of magnitudes faster
  • 🔧 Easily customizable parsing and writing
  • 🌿 Access to raw, unparsed bibtex.
  • 💩 Fault-Tolerant: Able to parse files with syntax errors
  • 🀄 Massively simplified, robuster handling of de- and encoding (special chars, ...).
  • ©️ Permissive MIT license

TLDR Usage Example

# Parsing a bibtex string with default values
bib_database = bibtexparser.parse_string(bibtex_string)
# Converting it back to a bibtex string, again with default values
new_bibtex_string = bibtexparser.write_string(bib_database)

Slightly more involved example:

# Lets parse some bibtex string.
bib_database = bibtexparser.parse_string(bibtex_string,
    # Middleware layers to transform parsed entries.
    # Here, we split multiple authors from each other and then extract first name, last name, ... for each
    append_middleware=[SeparateCoAuthors(), SplitNameParts()],
)

# Here you have a `bib_database` with all parsed bibtex blocks.

# Let's transform it back to a bibtex_string.
new_bibtex_string = bibtexparser.write_string(bib_database,
    # Revert aboves transfomration
    prepend_middleware=[MergeNameParts(), MergeCoAuthors()]
)

These examples really only show the bare minimum. Consult the documentation for a list of available middleware, parsing options and write-formatting options.

V2 Architecture and Terminology

bibtexparserv2

The architecture consists of the following components:

Library

Reflects the contents of a parsed bibtex files, including all comments, entries, strings, preamples and their metadata (e.g. order).

A Splitter

Splits a bibtex string into basic blocks (Entry, String, Preamble, ...), with correspondingly split content (e.g. fields on Entry, key-value on String, ...). The splitter aims to be forgiving when facing invalid bibtex: A line starting with a block definition (@....) ends the previous block, even if not yet every bracket is closed, failing the parsing of the previous block. Correspondingly, one block type is "ParsingFailedBlock".

Middleware

Middleware layers transform a library and its blocks, for example by decoding latex special characters, interpolating string references, resoling crossreferences or re-ordering blocks. Thus, the choice of middleware allows to customize parsing and writing to ones specific usecase. Note: Middlewares, by default, no not mutate their input, but return a modified copy.

Writer

Writes the content of a bibtex library to a .bib file. Optional formatting parameters can be passed using a corresponding dedicated data structure.

About

Since 2022, bibtexparser is primarily written and maintained by Michael Weiss (@MiWeiss). In 2024, Tom de Geus (@tdegeus) joined as co-maintainer.

Credits and thanks to the many contributors who helped creating this library, including François Boulogne (@sciunto, creator of the first version) and Olivier Mangin (@omangin, long-term contributor).

Metadata

Release files for bibtexparser 2.0.0b8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bibtexparser 2.0.0b8
File Size Uploaded Provenance
bibtexparser-2.0.0b8.tar.gz 37.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bibtexparser 2.0.0b8
File Interpreter ABI Platform
bibtexparser-2.0.0b8-py3-none-any.whl Python 3 none any Details

Total release size: 77.4 kB

Release files / bibtexparser-2.0.0b8.tar.gz

Download URL bibtexparser-2.0.0b8.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
11eaaa1fe80154f70092e91fa7e3fed5e5c81021f6c6c09151e36b8533f36994
BLAKE2b-256 checksum
How to use checksums
a3b6967e030d0f8359b912a64ce7447db485064862a4d3980cac07b398bc95be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / bibtexparser-2.0.0b8-py3-none-any.whl

Download URL bibtexparser-2.0.0b8-py3-none-any.whl
Size 39.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eda1e6dbc7bbc040d351c926ead97a36f4734858656f3514a933259878bd37f1
BLAKE2b-256 checksum
How to use checksums
cb4e226cfbf6c61c38399fc19e5f46db755ffea32f77ef078982c953031c8a3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for bibtexparser 2.0.0b8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page