A Python tool to convert BBL (bibliography) files generated by BibTeX back into BIB format. This is useful when you have a compiled BBL file but need to reconstruct the original bibliography database.
- 🔄 Automatic Entry Type Detection: Intelligently identifies entry types (article, book, inproceedings, etc.) based on content
- 📚 Smart Field Extraction: Extracts common fields like author, title, year, journal, pages, DOI, URL, etc.
- 🎨 Multiple Output Formats: Choose between standard, minimal, or full formatting styles
- 🚀 Batch Processing: Convert multiple BBL files at once
- 📝 Clean Output: Properly formatted BibTeX entries with correct field ordering
- 🔍 Robust Parsing: Handles various BBL formats and LaTeX commands
- Python 3.7 or higher
- No external dependencies (uses only Python standard library)
- Clone the repository:
git clone https://github.com/yourusername/bbl2bib.git
cd bbl2bib- Run the setup script (creates virtual environment automatically):
chmod +x setup.sh
./setup.sh- Make the wrapper script executable:
chmod +x bbl2bibIf you prefer to set up manually:
- Clone the repository:
git clone https://github.com/yourusername/bbl2bib.git
cd bbl2bib- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install the package:
pip install -e .- Make scripts executable (Unix/Mac only):
chmod +x bbl2bib.py bbl2bibThe easiest way to use bbl2bib is with the wrapper script that automatically handles the virtual environment:
./bbl2bib input.bblIf you prefer to manually activate the virtual environment:
source venv/bin/activate # On Windows: venv\Scripts\activate
python bbl2bib.py input.bblConvert a single BBL file to BIB:
./bbl2bib input.bbl
# or
python bbl2bib.py input.bbl # if venv is already activatedThis creates input.bib in the same directory.
./bbl2bib input.bbl -o output.bib./bbl2bib file1.bbl file2.bbl file3.bblOr use wildcards:
./bbl2bib *.bbl-o, --output: Specify output file name (only for single input file)-v, --verbose: Enable verbose output for debugging--overwrite: Overwrite existing output files without confirmation--format: Choose output format stylestandard(default): Well-formatted with proper indentationminimal: Compact format without extra spacingfull: Include additional formatting and protection for special characters
# Convert with verbose output
./bbl2bib references.bbl --verbose
# Convert all BBL files in directory with minimal format
./bbl2bib *.bbl --format minimal --overwrite
# Convert with full formatting (protects capitalization)
./bbl2bib thesis.bbl --format full -o thesis_bibliography.bib
# If you've already activated the virtual environment manually:
python bbl2bib.py references.bbl --verbose- Parsing: The tool reads the BBL file and identifies
\bibitementries - Analysis: Each entry is analyzed to determine:
- Entry type (article, book, etc.)
- Author names
- Title
- Publication details (journal, year, pages, etc.)
- Extraction: Fields are extracted using pattern matching and heuristics
- Formatting: Entries are formatted according to BibTeX standards
- Output: Clean BIB file is generated with proper structure
@article- Journal articles@book- Books@inproceedings- Conference papers@incollection- Book chapters@phdthesis- PhD dissertations@mastersthesis- Master's theses@techreport- Technical reports@misc- Miscellaneous entries
The tool attempts to extract the following fields when present:
- Basic: author, title, year
- Publication: journal, booktitle, publisher
- Details: volume, number, pages, edition
- Identifiers: doi, isbn, url
- Location: address, school, institution
- Other: month, note, editor, series
- The accuracy of conversion depends on the structure and formatting of the BBL file
- Some complex LaTeX formatting may not be perfectly preserved
- Custom bibliography styles might require manual adjustment of the output
- Field extraction relies on common patterns and may miss unconventional formatting
bbl2bib/
├── bbl2bib.py # Main script
├── parser/
│ ├── __init__.py
│ └── bbl_parser.py # BBL parsing logic
├── writer/
│ ├── __init__.py
│ └── bib_writer.py # BIB file writer
├── utils/
│ ├── __init__.py
│ └── logger.py # Logging utilities
├── examples/ # Example files
│ ├── sample.bbl
│ └── sample.bib
├── requirements.txt # Python dependencies
└── README.md # This file
Contributions are welcome! Please feel free to submit issues or pull requests.
- Clone the repository
- Install development dependencies:
pip install pytest black flake8 mypy- Run tests:
pytest tests/This project is licensed under the MIT License. See LICENSE file for details.
-
"No bibliography entries found"
- Check that your BBL file contains
\bibitementries - Ensure the file encoding is UTF-8
- Check that your BBL file contains
-
Missing fields in output
- The parser uses heuristics to extract fields
- Manual adjustment may be needed for unusual formats
-
Incorrect entry types
- Entry type detection is based on content patterns
- You can manually edit the output BIB file to correct types
- Check the examples directory for sample input/output files
- Use
--verboseflag for detailed parsing information - Report issues on GitHub with sample BBL content