22 releases (5 stable)

1.2.2 Mar 14, 2026
1.2.0 Feb 23, 2026
0.15.1 Dec 17, 2025
0.15.0 Nov 13, 2025
0.8.0 Nov 28, 2024

#281 in Parser implementations

Download history 2305/week @ 2025-12-09 2753/week @ 2025-12-16 1424/week @ 2025-12-23 1797/week @ 2025-12-30 3019/week @ 2026-01-06 3078/week @ 2026-01-13 2885/week @ 2026-01-20 3067/week @ 2026-01-27 3524/week @ 2026-02-03 3421/week @ 2026-02-10 4181/week @ 2026-02-17 4197/week @ 2026-02-24 4470/week @ 2026-03-03 4431/week @ 2026-03-10 4922/week @ 2026-03-17 4916/week @ 2026-03-24

19,509 downloads per month
Used in 3 crates

BSD-3-Clause

330KB
4K SLoC

nbformat - Jupyter Notebook Format in Rust

This crate provides functionality to parse and work with Jupyter Notebook files in Rust.

Usage

Add this to your Cargo.toml:

[dependencies]
nbformat = "0.1.0"

Here's a basic example of how to use parse_notebook:

use nbformat::{parse_notebook, Notebook};
use std::fs;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Read the notebook file
    let notebook_json = fs::read_to_string("Untitled1337.ipynb")?;

    // Parse the notebook
    let notebook = parse_notebook(&notebook_json)?;

    // Work with the parsed notebook
    match notebook {
        Notebook::V4(nb) => {
            println!("Notebook version: {}.{}", nb.nbformat, nb.nbformat_minor);
            println!("Number of cells: {}", nb.cells.len());
            // Access other notebook properties...
        }
        Notebook::Legacy(nb) => {
            println!("Legacy notebook version: {}.{}", nb.nbformat, nb.nbformat_minor);
            println!("Number of cells: {}", nb.cells.len());
            // Access other notebook properties...
        }
    }

    Ok(())
}

At present, this crate supports v4.5 notebooks via Notebook::V4, v4.1-v4.4 via Notebook::Legacy and v3 via Notebook::V3. v4.5 have some more hard constraints on CellIDs being required, only allowing certain characters, and not having duplicates. Converting from a v4.1-v4.4 notebook to a v4.5 notebook requires modifying the notebook to include Cell IDs.

ROADMAP

  • Serialize and Deserialize v4.1-v4.5 notebooks into rust structures
  • Test operations on a suite of notebooks from Python nbformat
  • Add support for upconverting v3 notebooks to v4
  • Add support for upconverting v4.1-v4.4 notebooks to v4.5
  • Break out types to be shared between runtimelib's Media setup and the notebook crate
  • Add support for v2 and v1 notebook upconversion

Dependencies

~2.3–4MB
~69K SLoC