Fast, lightweight notebook conversion library
Project description
notebookx
A fast, lightweight notebook conversion library written in Rust with Python bindings.
notebookx is a Rust-based alternative to Python's nbconvert, providing fast notebook conversion between formats like .ipynb and percent format (.pct.py).
Features
- Fast: Written in Rust for maximum performance
- Multiple interfaces: Use as a Rust library, CLI tool (
nbx), or Python package - Format conversion: Convert between ipynb and percent format
- Notebook cleaning: Strip outputs, execution counts, and metadata for version control
- Cross-platform: Works on Linux, macOS, and Windows
Installation
Python
pip install notebookx-py
Rust
Add to your Cargo.toml:
[dependencies]
notebookx = "0.1"
CLI
cargo install notebookx --features cli
Usage
Python
from notebookx import Notebook, Format, CleanOptions
# Load a notebook
nb = Notebook.from_file("example.ipynb")
# Convert to percent format
nb.to_file("example.pct.py")
# Or get as string
percent_content = nb.to_string(Format.Percent)
# Clean notebook for version control
clean_nb = nb.clean(CleanOptions(
remove_outputs=True,
remove_execution_counts=True,
))
clean_nb.to_file("clean.ipynb")
# Convenience functions
from notebookx import convert, clean_notebook
convert("input.ipynb", "output.pct.py")
clean_notebook("notebook.ipynb", remove_outputs=True)
CLI (nbx)
# Convert ipynb to percent format
nbx convert notebook.ipynb --to notebook.pct.py
# Convert percent to ipynb
nbx convert notebook.pct.py --to notebook.ipynb
# Clean a notebook (remove outputs)
nbx clean notebook.ipynb --output clean.ipynb --remove-outputs
# Clean in place
nbx clean notebook.ipynb --in-place --remove-outputs --remove-execution-counts
# Use stdin/stdout
cat notebook.ipynb | nbx convert - --from-fmt ipynb --to - --to-fmt percent
Rust
use notebookx::{Notebook, NotebookFormat, CleanOptions};
// Parse from file
let content = std::fs::read_to_string("example.ipynb")?;
let notebook = NotebookFormat::Ipynb.parse(&content)?;
// Convert to percent format
let percent = NotebookFormat::Percent.serialize(¬ebook)?;
// Clean notebook
let options = CleanOptions {
remove_outputs: true,
remove_execution_counts: true,
..Default::default()
};
let clean = notebook.clean(&options);
// Save to file
let output = NotebookFormat::Ipynb.serialize(&clean)?;
std::fs::write("clean.ipynb", output)?;
Supported Formats
| Format | Extension | Description |
|---|---|---|
| ipynb | .ipynb |
Standard Jupyter notebook format (JSON) |
| percent | .pct.py |
Percent format used by Jupytext, VSCode, etc. |
Clean Options
When cleaning notebooks, you can control what gets removed:
| Option | Description |
|---|---|
remove_outputs |
Remove all cell outputs |
remove_execution_counts |
Reset execution counts to null |
remove_cell_metadata |
Remove cell-level metadata |
remove_notebook_metadata |
Remove notebook-level metadata |
remove_kernel_info |
Remove kernel specification |
preserve_cell_ids |
Keep cell IDs (default: regenerate) |
remove_output_metadata |
Remove metadata from outputs |
remove_output_execution_counts |
Remove execution counts from outputs |
Presets
Python:
# For version control (removes cell metadata, execution counts, and output metadata)
# Preserves outputs so rendered content remains visible
options = CleanOptions.for_vcs()
# Strip everything (including outputs)
options = CleanOptions.strip_all()
CLI Reference
nbx convert
Convert notebooks between formats.
nbx convert <INPUT> --to <OUTPUT> [OPTIONS]
Options:
--from-fmt <FORMAT> Input format (ipynb, percent). Inferred from extension if not specified.
--to-fmt <FORMAT> Output format (ipynb, percent). Inferred from extension if not specified.
-h, --help Print help
nbx clean
Clean notebooks by removing outputs and metadata.
nbx clean <INPUT> [OPTIONS]
Options:
-o, --output <FILE> Output file (default: stdout)
-i, --in-place Modify file in place
-O, --remove-outputs Remove all outputs
-e, --remove-execution-counts Remove execution counts
--remove-cell-metadata Remove cell metadata
--remove-notebook-metadata Remove notebook metadata
--remove-kernel-info Remove kernel specification
-h, --help Print help
Development
Building from source
# Clone the repository
git clone https://github.com/lukastk/notebookx.git
cd notebookx
# Build Rust library and CLI
cargo build --release
# Build Python package
pip install maturin
maturin develop
Running tests
# Rust tests
cargo test --workspace
# Python tests
pytest tests/python
License
MIT
Acknowledgements
Example notebooks in nb_format_examples/ are from the Jupytext demo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 notebookx_py-0.1.1.tar.gz.
File metadata
- Download URL: notebookx_py-0.1.1.tar.gz
- Upload date:
- Size: 37.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
586b222688fb6f32f72c83c0bb119bceb852b0158ac534c1abaf7442cde7f931
|
|
| MD5 |
3014e4a4da5133c9d559e13f50e1d034
|
|
| BLAKE2b-256 |
f3f8de3997b2c7d16b386921156547b29d7a1c787cef34c9e05889e51bf51688
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1.tar.gz:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1.tar.gz -
Subject digest:
586b222688fb6f32f72c83c0bb119bceb852b0158ac534c1abaf7442cde7f931 - Sigstore transparency entry: 781960124
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 752.7 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fdddf4fa45740f5a909084a8674fa279cbfd820b4f1a5db80d1c0803129b7f0
|
|
| MD5 |
4e397e0f6b1b4a1f09f1f28ebf831ec6
|
|
| BLAKE2b-256 |
bf553600799f31972d7ee07cba52282e84fa3706d4d99598afd1d8e3f159ad0a
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
7fdddf4fa45740f5a909084a8674fa279cbfd820b4f1a5db80d1c0803129b7f0 - Sigstore transparency entry: 781960137
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 754.7 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c3d7351c24e3eeb495f44cb1a18c059d70da3c64ac04b4aa1e2beaf1f08324d
|
|
| MD5 |
0ac6279e46628393027cccbd2270163c
|
|
| BLAKE2b-256 |
0d92b30bf17abe1f2310dbae2a89f1c95fd5e760dd48d9d01fb21f3dba7e850d
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
8c3d7351c24e3eeb495f44cb1a18c059d70da3c64ac04b4aa1e2beaf1f08324d - Sigstore transparency entry: 781960131
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 591.3 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b6a4c143db0256c4ebf01f89eebab486964dbdbe57d547d0e10a25f53df2ec4
|
|
| MD5 |
7302217e24f1d8b6af1de09d150c625b
|
|
| BLAKE2b-256 |
e8dbfa1e4ab14cac2ffad803c4c8d7e33e3fb9cde45f89cee4d76d8cb6ffcfb8
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-cp38-abi3-win_amd64.whl -
Subject digest:
5b6a4c143db0256c4ebf01f89eebab486964dbdbe57d547d0e10a25f53df2ec4 - Sigstore transparency entry: 781960127
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 775.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
befa80443750dfd2a0da9a7551debc5836b938ef742295152a32730422e1bf86
|
|
| MD5 |
cb5dbd8ef70204816eb814592101783e
|
|
| BLAKE2b-256 |
799df2469d0e70e52aaaea42864f60b38a28581120d5c8204ca3c924066d116d
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
befa80443750dfd2a0da9a7551debc5836b938ef742295152a32730422e1bf86 - Sigstore transparency entry: 781960133
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 753.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c3e83086e3b45e1f2e8de4fd6298287c6946cce43834829d1b8bf772e5809e0
|
|
| MD5 |
1810e0c1f366a55c1f7016d2e4a8f0cf
|
|
| BLAKE2b-256 |
02ee92366f7444c27a1bb06a0fb4991a3fd523fb56e2e938f1a10a537153b60e
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
3c3e83086e3b45e1f2e8de4fd6298287c6946cce43834829d1b8bf772e5809e0 - Sigstore transparency entry: 781960136
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 697.0 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4df8b54dd75a3fe1f45c551ffb203d7c3694a5cb51f83aec76e2f4e548236e05
|
|
| MD5 |
474a6baa263b568574d62585c82aea43
|
|
| BLAKE2b-256 |
f012bcc32b0dded3f070265e95a3c183de5ecf91303659182f3bcfb7912d563a
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
4df8b54dd75a3fe1f45c551ffb203d7c3694a5cb51f83aec76e2f4e548236e05 - Sigstore transparency entry: 781960130
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file notebookx_py-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: notebookx_py-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 724.2 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff0556d4fe18c748713115cfe9b9510d7483e41f777d5e10902851df400586a1
|
|
| MD5 |
79d0ce299185c3dbcbf2b93217b3eb23
|
|
| BLAKE2b-256 |
b40292e250437637081dbcbcdd7e4d523b540791934e5a78cba6a46256837050
|
Provenance
The following attestation bundles were made for notebookx_py-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on lukastk/notebookx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notebookx_py-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl -
Subject digest:
ff0556d4fe18c748713115cfe9b9510d7483e41f777d5e10902851df400586a1 - Sigstore transparency entry: 781960128
- Sigstore integration time:
-
Permalink:
lukastk/notebookx@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/lukastk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8edee437338ad9b590860b3755b7a7a9eab68b5 -
Trigger Event:
push
-
Statement type: