How to Recover Deleted Files in Jupyter Notebook: 6 Methods

Learn how to recover deleted files in Jupyter Notebook

Wondering how to recover deleted files in Jupyter Notebook after removing a cell, deleting an .ipynb file, or saving an unwanted change? Start by identifying what disappeared. A deleted cell, a missing notebook file, and a notebook stored on a remote JupyterHub need different solutions. This guide walks through each case in the safest order. For broader deleted file recovery on a local Windows drive, Magic Data Recovery can scan for a missing notebook when Jupyter’s own recovery options and backups cannot help.

Do this first: Stop saving files, installing packages, clearing caches, or running cleanup tools on the drive that held the notebook. New data may overwrite a permanently deleted .ipynb file.

Supports Windows 7/8/10/11 and Windows Server

Table of Contents

What Exactly Did You Delete in Jupyter Notebook?

An .ipynb notebook is a JSON document that stores code cells, Markdown cells, outputs, and metadata. However, the live kernel also keeps an input history for code you have executed. That distinction explains why you may recover code from history without recovering the complete notebook.

Use this quick diagnosis before trying a fix:

What went missing?

Best first method

What the method can restore

One or more cells, with the notebook still open

Press Z in command mode

Recently deleted cells

Cells or edits saved over the current notebook

Revert to a checkpoint or earlier version

A previously saved notebook state

The entire local .ipynb file

Check Recycle Bin or Trash

The complete file, if it was moved there

Executed code, but no usable notebook copy remains

Search IPython history

Code inputs, not the full notebook structure

A notebook in JupyterHub, a course lab, or another hosted service

Check platform history or contact the administrator

Server-side backups, snapshots, or trash

A local Windows notebook missing from Trash and backups

Scan the original drive

A recoverable deleted .ipynb file or other project files

Recover Deleted Files in Jupyter Notebook: 6 Methods

Work through the following solutions in order. The early methods do not scan deleted disk space, so they are faster and less invasive.

Method 1: Undo a Deleted Cell Immediately

If you deleted a cell but the notebook is still open, Jupyter’s cell-operation history offers the quickest fix.

  1. Press Esc to enter command mode.
  2. Press Z once.
  3. Check whether the deleted cell returns in its former position.
  4. Save the notebook under a new name before making more changes.

The current JupyterLab command reference lists Z as the shortcut for Undo Cell Operation. You can also open the Edit menu or Command Palette and choose that command. If you deleted several cells, repeat it carefully.

Do not confuse Z with Ctrl+Z or Cmd+Z. The single-key command reverses a notebook-level cell action while you are in command mode. The standard shortcut usually undoes text edits inside an active cell.

This option works best before you close or reload the notebook. If the undo history is gone, move to the checkpoint method.

Method 2: Restore a Jupyter Notebook Checkpoint

Checkpoints contain an earlier saved state of a notebook. They are useful when you deleted cells, replaced working code, or saved a broken edit over the original file.

Revert from the Jupyter interface

Before reverting, make a copy of the current notebook. Then open the File menu and look for Revert Notebook to Checkpoint or a similarly named command. Menu wording can vary between Jupyter Notebook and JupyterLab versions.

Select the available checkpoint and review its timestamp. Reverting replaces the current notebook state, so copy any newer cells you still need before confirming.

Recover the checkpoint file manually

Jupyter commonly stores checkpoint copies inside a hidden folder beside the notebook:

  1. project/
  2. ├── analysis.ipynb
  3. └── .ipynb_checkpoints/
  4. └── analysis-checkpoint.ipynb

If the checkpoint remains, copy it to a different folder and rename the copy, for example:

  1. analysis-recovered.ipynb

Open the renamed copy in Jupyter and verify the cells. Do not edit the only checkpoint directly.

A checkpoint is not a complete version-control system. It may contain only one older state, and it may not exist if the notebook was never saved. In addition, deleting a notebook through some interfaces can remove associated checkpoint data. Therefore, check this location early but do not rely on it as your only backup.

Method 3: Restore the Deleted .ipynb File from Trash

If the entire file disappeared, inspect the operating system before using recovery software. Jupyter Notebook’s official release notes document support for sending files deleted from the Notebook dashboard to the operating system’s trash instead of erasing them immediately.

On Windows

  1. Open Recycle Bin.
  2. Search for the notebook name or sort by Date Deleted.
  3. Confirm that the file ends in .ipynb.
  4. Right-click it and choose Restore.
  5. Return to its original project folder and open a copy.

On macOS

Open Trash, locate the notebook, right-click it, and choose Put Back. If you used Finder or Terminal to delete the file, also search by filename in Finder.

On Linux

Check your desktop environment’s Trash. A common location is:

  1. ~/.local/share/Trash/files/

The actual location may differ on a managed workstation, container, or remote server. Also search the project directory in case the notebook was renamed or moved instead of deleted.

Files removed with Shift+Delete, a terminal command such as rm, or a cleanup process may bypass Trash. Removable drives and network shares may behave differently as well.

Method 4: Recover Executed Code from IPython History

Suppose the notebook file is gone, yet its kernel or IPython history remains. You may still rebuild much of the code. Run these commands in a new notebook or IPython console:

  1. %history -n

This prints code inputs from the current session with line numbers. To search saved history for a distinctive function, variable, import, or comment, use a glob pattern:

%history -g “customer_churn

To inspect recent inputs across sessions, try:

%history -l 100

Once you identify the needed range, export it to a new script:

%history -f recovered_notebook_code.py 4-38

Use a filename that does not already exist. The official IPython documentation warns that the -f option can overwrite the destination file from a notebook interface.

This is a valuable way to recover deleted code in Jupyter Notebook, but it has firm limits. IPython history focuses on inputs. It does not recreate Markdown explanations, cell ordering with complete fidelity, images attached to Markdown cells, notebook metadata, or every displayed output. Code that you typed but never executed may also be absent.

Method 5: Check Backups, Sync History, Git, or the Host Platform

When checkpoints fail, look outside Jupyter. The correct place depends on where the .ipynb file lived.

  • Windows File History or Previous Versions: Open the notebook’s former folder, check its properties, and look for a version from before deletion.
  • OneDrive, Dropbox, or Google Drive: Inspect the cloud trash and version history if the project folder was synced.
  • Git: Check git status, the repository history, other branches, stashes, and remote copies. Git can restore only content that was committed or otherwise preserved.
  • JupyterHub or a university/company server: Ask the administrator about snapshots, server trash, backups, and retention periods.
  • Course platforms and hosted labs: Look for reset, restore, history, or re-download options before resetting the workspace. A reset may replace your current files.

This location check matters. A local data recovery program cannot directly scan a notebook that existed only on a remote JupyterHub server. In that case, the service owner or administrator controls the storage and backups.

Method 6: Recover a Deleted Jupyter Notebook with Magic Data Recovery

Use disk recovery only after Recycle Bin, checkpoints, history, and backups fail. This method fits a notebook that was stored on a Windows PC, external drive, USB device, or another storage device that you can connect to Windows.

Magic Data Recovery addresses a wider set of local data-loss cases than Jupyter’s built-in tools. It can scan for files lost through deletion, formatting, file-system errors, inaccessible partitions, or related logical problems. Its guided scan-and-recover workflow also avoids the command syntax required by some recovery utilities.

How to recover a local .ipynb file

1. Protect the source drive. Stop using the volume that contained the notebook. If the file was on C:, avoid downloading or installing anything there when possible.

2. Install safely. Download Magic Data Recovery to another drive or run it from a Windows computer that is not using the affected disk as its system drive.

Supports Windows 7/8/10/11 and Windows Server

3. Select the original location. Choose the disk or partition where the project folder existed, then start the scan.

Recover a Deleted Jupyter Notebook with Magic Data Recovery

4. Narrow the results. Search for the notebook name, .ipynb, its former folder, or the approximate modification date. A recovered notebook may appear under Documents or Other Files, depending on the remaining file-system information.

recover a local .ipynb file

5. Recover to a different drive. Never save the result back to the source volume.

Recover to a different drive

6. Validate the recovered copy. Open it in Jupyter. If Jupyter reports invalid content, inspect a duplicate in a text editor and confirm that it contains coherent JSON rather than a partial or overwritten file.

Magic Data Recovery is more practical than a checkpoint when the checkpoint disappeared with the original notebook, and more complete than IPython history when the underlying .ipynb file remains recoverable. It can also scan other project assets that history cannot reconstruct, such as CSV files, images, scripts, and documents.

Still, no recovery tool can promise a specific result. SSD TRIM, continued disk use, secure deletion, or physical damage may make recovery impossible. The software also cannot retrieve a file stored only on a remote server unless you first obtain access to that server’s storage or a local disk image.

Which Jupyter Notebook Recovery Method Should You Choose?

Method

Best for

Main limitation

Z / Undo Cell Operation

A cell deleted moments ago

Undo history may disappear after closing or reloading

Checkpoint

Saved-over cells or an unwanted notebook state

Usually limited history; may be missing

Recycle Bin or Trash

A recently deleted local .ipynb file

Permanent deletion may bypass it

IPython %history

Rebuilding executed code

Does not restore a complete notebook

Backup, sync, Git, or server snapshot

Preserved earlier copies

Must have existed before the loss

Magic Data Recovery

A deleted local file or logical storage problem on Windows

Cannot recover overwritten data or scan remote-only storage

In practice, the best sequence is undo → checkpoint → Trash → history → backup → disk scan. That order protects current data and uses the most direct recovery source first.

How to Prevent Another Jupyter Notebook Loss

Once you recover the work, improve the project rather than trusting checkpoints alone.

  • Put important notebooks under Git and commit meaningful milestones.
  • Keep the project inside a backed-up or versioned folder.
  • Export critical notebooks to .py or HTML at key stages.
  • Save raw data separately from generated outputs.
  • Use clear filenames instead of keeping everything as Untitled.ipynb.
  • Confirm the notebook’s actual path with %pwd, especially when using remote kernels or mounted drives.
  • Test your backup restoration process before an emergency.

For active research, a simple habit works well: commit the notebook before a major refactor, then save a second copy before clearing cells or outputs.

Conclusion

Learning how to recover deleted files in Jupyter Notebook starts with distinguishing a deleted cell from a deleted .ipynb file. Press Z for a recent cell deletion, inspect checkpoints for an earlier saved state, check the operating system’s Trash for the complete file, and use IPython history when you mainly need executed code. For hosted notebooks, contact the platform owner and look for server-side snapshots.

When the missing notebook lived on a local Windows drive and those options fail, Magic Data Recovery is worth trying because it covers permanent deletion, formatted storage, and file-system errors through a clear scan-and-recover process. It also helps retrieve related project files that Jupyter history cannot rebuild. Act quickly, scan the correct device, and restore results elsewhere. For more guidance on safely restoring erased data, visit Amagicsoft’s deleted file recovery resource.

Supports Windows 7/8/10/11 and Windows Server

FAQs About Jupyter Notebook File Recovery

Can I recover a deleted cell in Jupyter Notebook?

Yes. If the notebook remains open, press Esc to enter command mode, then press Z to undo the last cell operation. You can also choose Undo Cell Operation from the menu or Command Palette. Save a copy immediately after the cell returns.

Where are Jupyter Notebook checkpoint files stored?

Jupyter commonly stores them in a hidden .ipynb_checkpoints folder beside the original notebook. A file named analysis.ipynb may have a checkpoint named analysis-checkpoint.ipynb. The folder or checkpoint may not exist if the notebook was never saved or its checkpoint was removed.

Can a checkpoint recover an entirely deleted notebook?

Sometimes, but not reliably. A checkpoint may survive when the original file was deleted outside Jupyter, yet some deletion workflows remove associated checkpoint data. Check .ipynb_checkpoints, copy any candidate elsewhere, rename it with an .ipynb extension, and open the copy.

Does %history restore the whole Jupyter Notebook?

No. %history can retrieve code inputs recorded by IPython, including inputs from earlier sessions in many setups. It does not fully reproduce Markdown cells, rich outputs, attachments, metadata, or exact cell order. Treat it as a way to rebuild code, not the complete notebook.

Where do deleted Jupyter Notebook files go?

Files deleted through modern Jupyter interfaces often go to the operating system's Recycle Bin or Trash. However, terminal commands, permanent-delete shortcuts, remote servers, containers, and custom content managers may behave differently. Check both local Trash and any server- or platform-specific recovery area.

Can Magic Data Recovery recover an .ipynb file?

It may recover a deleted .ipynb file from accessible Windows storage if its data and file-system records have not been overwritten. Search scan results by filename, extension, path, and date, then restore candidates to another drive. Recovery results depend on the device and later disk activity.

Can I recover a notebook deleted from JupyterHub?

Possibly, but recovery depends on the host. JupyterHub notebooks usually reside on server-managed storage, so check the platform's trash, snapshots, sync history, or backups. Contact the administrator promptly. Local recovery software cannot directly scan a remote-only server file without storage access.

What should I do immediately after deleting a notebook?

Stop writing to the affected storage. Do not install packages, clear caches, format the drive, or recreate a file with the same name. Check undo, checkpoints, Trash, history, and backups first. If the file was local and permanently deleted, scan from another drive.

Jason has over 15 years of hands-on experience in the computer data security industry. He specializes in data recovery, backup and restoration, and file repair technologies, and has helped millions of users worldwide resolve complex data loss and security issues.