nb4llm
Convert Jupyter notebooks to and from a readable, LLM-friendly text format.
🚀 Features
- Convert
.ipynb→.txt: Extracts markdown and code cells as readable, chunked blocks. - Convert
.txt→.ipynb: Reconstructs a notebook from the text format. - Language-aware: Preserves code cell language (Python, R, Julia, etc).
- Robust chunking: Handles nested code fences and markdown.
- CLI tool: Easy to use from the command line or scripts.
- Pre-commit, Black, isort, flake8: Modern Python dev workflow.
📦 Installation
pip install -e .
# or, for development:
pip install -e .[dev]
📝 Usage
Convert a notebook to text
nb4llm notebook.ipynb
# Output: notebook.txt
Convert a notebook to a specific text file
nb4llm notebook.ipynb output.txt
Convert text back to a notebook
nb4llm --reverse notebook.txt
# Output: notebook.ipynb
Convert text to a specific notebook file
nb4llm --reverse notebook.txt output.ipynb
Show help
nb4llm --help
🧑💻 Example Text Format
# my_notebook.ipynb
```markdown
Some markdown text
# Some code
print(\"Hello, world!\")
---
## 🛠️ Development
### **Run tests**
```bash
pytest tests/
Run formatting and linting
pre-commit run --all-files
Type checking
mypy src/
🧩 Project Structure
nb4llm/
├── src/
│ └── nb4llm/
│ ├── __init__.py
│ ├── cli.py
│ └── converter.py
├── tests/
│ ├── test_cli.py
│ ├── test_converter.py
│ └── conftest.py
├── pyproject.toml
├── .pre-commit-config.yaml
├── .flake8
└── README.md
📝 Contributing
- Fork the repo and create a feature branch.
- Make your changes and add tests.
- Run
pre-commit run --all-filesandpytest. - Submit a pull request!
📄 License
MIT License. See LICENSE for details.
Built for robust, LLM-friendly notebook processing.
Let me know if you want this written to your README.md or want to tweak any section!
Contact
name: Amber Malpas github: AmberLee2427 email: malpas.1@osu.edu
Metadata
Release files for nb4llm 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nb4llm-0.1.3.tar.gz | 9.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nb4llm-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.1 kB
Release files / nb4llm-0.1.3.tar.gz
| Download URL | nb4llm-0.1.3.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62962d1f95cff3ca2d519f352717cb5c8ee9f8fed082adc46eed401fa4539473
|
|
BLAKE2b-256 checksum How to use checksums |
c2a76321afaa5b3cbcfe144a2827ac0aeec7cfcc7c67dda3548e158631ccce01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / nb4llm-0.1.3-py3-none-any.whl
| Download URL | nb4llm-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e51e3db6154d2982009667aa485e989728c577e6f4671cd9a18cf5f11d3cc32b
|
|
BLAKE2b-256 checksum How to use checksums |
878f560f231d35e86054fe452522029030f53cd5218e35e6617767fbd24f55d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Security for nb4llm 0.1.3
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.