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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nb4llm-0.1.3.tar.gz
(9.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nb4llm-0.1.3.tar.gz.
File metadata
- Download URL: nb4llm-0.1.3.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62962d1f95cff3ca2d519f352717cb5c8ee9f8fed082adc46eed401fa4539473
|
|
| MD5 |
e47f15437493df16a4f1821aaf88cbaa
|
|
| BLAKE2b-256 |
c2a76321afaa5b3cbcfe144a2827ac0aeec7cfcc7c67dda3548e158631ccce01
|
File details
Details for the file nb4llm-0.1.3-py3-none-any.whl.
File metadata
- Download URL: nb4llm-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e51e3db6154d2982009667aa485e989728c577e6f4671cd9a18cf5f11d3cc32b
|
|
| MD5 |
6aeda0a732464b7801a650d7cbad8f2e
|
|
| BLAKE2b-256 |
878f560f231d35e86054fe452522029030f53cd5218e35e6617767fbd24f55d9
|