# Jupyter Notebook to Reproducible Script Linearizer

Turn .ipynb into a # %% Python script and detect out-of-order, hidden, and deleted state

> Canonical page: https://elysiatools.com/en/tools/jupyter-notebook-to-reproducible-script-linearizer

- **Category:** Data Processing

- **Keywords:** Jupyter, ipynb, notebook, reproducibility, Python script, cell order, hidden state, nbconvert

## Overview

Linearizes code by execution_count or document order and statically checks use-before-definition, mutable cross-cell state, references after deletion, random seeds, file paths, environment dependencies, and notebook magics.

## Inputs

- **Notebook Input** (textarea): Paste the JSON content of an .ipynb file
- **Notebook File** (file)
- **Cell Order** (select)
- **Include Markdown as comments** (checkbox)

## When to use

- Review a notebook that only runs correctly after cells are executed out of order.
- Create a linear Python script for inspecting notebook code and cell dependencies.
- Find reproducibility risks such as use-before-definition, mutable cross-cell state, paths, seeds, and notebook magics.

## How it works

- Paste the JSON content of an .ipynb file or provide a supported notebook file.
- Choose Execution order to follow execution_count values or Document order to follow the notebook layout.
- Choose whether Markdown cells should appear as comments in the generated script.
- The tool returns linearized Python and a report covering detected state and environment-related risks.

## Use cases

- Audit exploratory data analysis notebooks before sharing them with teammates.
- Inspect machine learning notebooks that depend on hidden execution state.
- Prepare notebook code for reproducibility reviews by exposing cell order and cross-cell references.

## Frequently asked questions

### What input does the tool accept?

It accepts pasted .ipynb JSON or a notebook file using supported JSON or plain-text MIME types.

### How are notebook cells ordered?

Cells can be ordered by execution count or by their document order.

### Does the output include Markdown cells?

Yes, Markdown can be included as comments when the option is enabled.

### What reproducibility issues can it detect?

It checks for use-before-definition, mutable cross-cell state, references after deletion, random seeds, file paths, environment dependencies, and notebook magics.

### What does the tool produce?

It produces text containing a reproducibility report and a linearized Python script with # %% markers.

## Related tools

- [Data URI Generator](https://elysiatools.com/en/tools/data-uri-generator): Convert files into Data URIs (Base64 or percent-encoded) for inlining images, fonts, and assets directly into HTML, CSS, or Markdown
- [CSV to Database Migration Planner](https://elysiatools.com/en/tools/csv-to-database-migration-planner): Infer a relational schema from CSV data and generate create-table plus ALTER migration plans for PostgreSQL, MySQL, SQLite, or SQL Server
- [Encrypted PDF Converter](https://elysiatools.com/en/tools/encrypted-pdf-converter): Open password-protected PDFs with OpenDataLoader and export them as Markdown, JSON, or text once the correct password is provided
- [OCR PDF to Structured JSON Bridge](https://elysiatools.com/en/tools/ocr-pdf-to-structured-json-bridge): Extract the PDF text layer with geometry (lines by y-position, tables by column gaps, headings by font size, colon key-value pairs), then fill a user-supplied JSON Schema field by field — labels matched by normalized keys, values coerced to declared types and validated with ajv.
- [Podcast Chapter Marker Builder](https://elysiatools.com/en/tools/podcast-chapter-marker-builder): Build every podcast chapter format from one timecoded list: Podcasting 2.0 JSON + RSS tag, ID3v2.4 CHAP+CTOC burned into an MP3, Vorbis comments, mp4chaps, YouTube timestamps and SRT, with a per-player support matrix.
- [Train/Test Split with Stratification](https://elysiatools.com/en/tools/train-test-split-with-stratification): Class-stratified train/validation/test split or stratified k-fold for CSV/JSON datasets — seeded, reproducible, with distribution reports, leakage checks, SMOTE preview and CSV export.
- [Text Encoding Forensics and Repair](https://elysiatools.com/en/tools/text-encoding-forensics-and-repair): Inspect text encoding, BOM, newline style and mojibake symptoms, then produce a scored local repair candidate.
- [Chat Transcript to PDF](https://elysiatools.com/en/tools/chat-transcript-to-pdf): Lay out multi-role chat transcripts into a PDF conversation

## Samples

- [PDF Samples](https://elysiatools.com/en/samples/pdf-samples): Generated PDF samples from tools dated 2026-02-01 to 2026-02-10
- [Distributed Tracing Samples](https://elysiatools.com/en/samples/distributed-tracing-samples): Comprehensive distributed tracing examples using Jaeger, OpenTelemetry, and other modern observability tools for microservices architecture
- [JWT Samples](https://elysiatools.com/en/samples/jwt-samples): Comprehensive JWT examples from basic token structure to advanced security implementations
- [WebRTC Real-Time Communication Samples](https://elysiatools.com/en/samples/webrtc-samples): Comprehensive WebRTC samples for peer-to-peer audio/video communication, data channels, screen sharing, and signaling server implementation
