Merging Student Jupyter Notebooks for Grading Without Losing the Plot
How to stack lab notebooks in a sensible order, when a ZIP of separate files is better than a merge, and how to keep kernel metadata honest.

Merging notebooks is easy. Merging them so you can still grade is a design problem. The merger does not know which cell belongs to which student unless you tell it.
Tool: /ipynb-merger. Split later if needed: /ipynb-splitter.
When a merge helps
Use one file when you will read top to bottom: a teaching packet (setup + exercises + solutions), a group project that is supposed to read as one narrative, or your own weekly labs combined for a supervisor.
Do not merge 30 independent student submissions into one 2,000-cell notebook “to make grading faster.” You will lose names, kernels, and patience. Zip the originals. Grade in the viewer, one file at a time.
A packet that holds together
- First file: your assignment skeleton or a Markdown-only cover (
# Lab 4, due date, honor code). That file’s kernelspec becomes the merge metadata. - Then each student’s notebook, with “Markdown section per source file” enabled so a heading shows where their work starts. Rename files to
01-ada.ipynbbefore you queue them if names matter. - Strip or compress after the merge if the packet is going anywhere public. Five labs of PNG plots will fail Git and email. See strip outputs before Git.
- Preview the combined cells before you download. Order errors are cheaper to fix in the queue than in Word.
Kernel and package mismatches
If student A used python3 and student B used a conda env with extra magics, the merged notebook still opens, but cells may not re-run. For grading reading, that is often fine. For grading execution, keep files separate or require a listed environment on the syllabus.
Split is not undo
Heading-based split is for your teaching notebook that already uses # titles. It will not magically recover student identity from a merge unless those headers exist. Keep the source files.
Privacy
Student notebooks contain names, sometimes IDs, sometimes data from surveys. Merge processes uploads for that request and does not keep a class archive. That does not make the download FERPA-safe. Store the merged file where your institution already stores submissions.
Related
- Honest upload behavior: what happens when you upload
- Broken JSON from a bad student zip: repair guide
FAQ: grading with merged notebooks
No. Merge when you will scroll one story. If you only need an archive, zip the originals. A 15-student merge with plots will be unreadable.
The first file in the queue supplies kernelspec metadata. Align student environments, or note mismatches in a Markdown cell at the top.
Only if you added section headers per source file or you kept the originals. Splitting by headings is not a perfect inverse of a messy merge.

