Convert IPYNB to FB2
Max file size 100mb.
IPYNB vs FB2 Format Comparison
| Aspect | IPYNB (Source Format) | FB2 (Target Format) |
|---|---|---|
| Format Overview |
IPYNB
Jupyter Notebook
Interactive computational notebook format used in data science, machine learning, and scientific computing. Contains code cells, markdown text, and rich output including visualizations. Based on JSON structure with cells for code execution and documentation. Interactive Data Science |
FB2
FictionBook 2
FB2 (FictionBook) is an XML-based ebook format popular in Russia and Eastern Europe. It stores the entire book structure including metadata, chapters, footnotes, and images in a single XML file. FB2 separates content from presentation, allowing reading applications to control the visual layout. Ebook XML-Based |
| Technical Specifications |
Structure: JSON with cells array
Encoding: UTF-8 JSON Format: Open format (Jupyter/IPython) Cell Types: Code, Markdown, Raw Extensions: .ipynb |
Structure: Single XML document with schema
Encoding: UTF-8 XML Standard: FictionBook 2.0 schema (XSD) Images: Base64-encoded inline binaries Extensions: .fb2, .fb2.zip |
| Syntax Examples |
IPYNB uses JSON cell structure: {
"cell_type": "code",
"source": ["import pandas as pd\n",
"df = pd.read_csv('data.csv')"],
"outputs": [{"output_type": "stream",
"text": [" col1 col2\n"]}]
}
|
FB2 uses XML structure for book content: <FictionBook>
<description>
<title-info>
<book-title>My Book</book-title>
<author><first-name>John</first-name>
<last-name>Doe</last-name></author>
</title-info>
</description>
<body>
<section><p>Content here</p></section>
</body>
</FictionBook>
|
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2014 (Project Jupyter)
Current Version: nbformat 4.5 Status: Active, widely adopted Evolution: From IPython Notebook to Jupyter ecosystem |
Introduced: 2004 (Russia)
Current Version: FB2 2.1 Status: Stable, widely used in Eastern Europe Evolution: From FictionBook 1.0 to FB2 with XML schema |
| Software Support |
Jupyter: Native format
VS Code: Full support Google Colab: Full support Other: JupyterLab, nteract, Kaggle, DataBricks |
Readers: FBReader, CoolReader, AlReader
Desktop: Calibre, FBReader Desktop Mobile: FBReader (Android/iOS), Moon+ Reader Converters: Calibre, fb2edit, Pandoc |
Why Convert IPYNB to FB2?
Converting Jupyter Notebooks to FB2 format allows you to read your notebook content using FBReader and other FB2-compatible reading applications. FB2 is particularly popular for ebook reading on Android devices and in the Russian-speaking digital book ecosystem.
FB2's self-contained XML structure means the entire book, including metadata and images, is stored in a single file. This makes it easy to share, archive, and manage converted notebooks as ebooks. The format's rich metadata support allows you to specify title, author, and subject information.
For users who prefer FBReader or CoolReader for their ebook reading, converting notebooks to FB2 provides a familiar reading experience. The format's reader-controlled layout means the reading application optimizes text display for the device's screen size.
Key Benefits of Converting IPYNB to FB2:
- FBReader Compatible: Read in the popular FBReader app and other FB2 readers
- Self-Contained: Single XML file with all content and images
- Rich Metadata: Preserve title, author, and subject information
- Structured Chapters: Notebook sections become navigable chapters
- Offline Reading: Download and read without internet connection
- Android Friendly: Popular format with excellent Android reader support
- Archival Format: XML-based format suitable for long-term preservation
Practical Examples
Example 1: Python Course Notebook to FB2
Input IPYNB file (notebook.ipynb):
{
"cells": [
{
"cell_type": "markdown",
"source": ["# Python for Beginners\n",
"## Chapter 1: Variables and Data Types\n",
"Python supports several built-in data types."]
},
{
"cell_type": "code",
"source": ["name = 'Alice'\n",
"age = 30\n",
"height = 5.7\n",
"is_student = True\n",
"print(f'{name} is {age} years old')\n",
"print(f'Height: {height} ft, Student: {is_student}')"],
"outputs": [{"text": "Alice is 30 years old\nHeight: 5.7 ft, Student: True"}]
}
]
}
Output FB2 file (notebook.fb2):
<FictionBook>
<description>
<title-info>
<book-title>Python for Beginners</book-title>
</title-info>
</description>
<body>
<section>
<title>Chapter 1: Variables and Data Types</title>
<p>Python supports several built-in
data types.</p>
<p>[Code]</p>
<p>name = 'Alice'</p>
<p>age = 30</p>
<p>height = 5.7</p>
<p>is_student = True</p>
<p>print(f'{name} is {age} years old')</p>
<p>Output: Alice is 30 years old</p>
<p>Height: 5.7 ft, Student: True</p>
</section>
</body>
</FictionBook>
Example 2: Data Analysis Book to FB2
Input IPYNB file (analysis.ipynb):
{
"cells": [
{
"cell_type": "markdown",
"source": ["# Exploratory Data Analysis Cookbook\n",
"## Recipe: Detecting Outliers\n",
"Use the IQR method to find outliers in your data."]
},
{
"cell_type": "code",
"source": ["import numpy as np\n",
"data = [12, 15, 14, 10, 100, 13, 11, 14]\n",
"q1, q3 = np.percentile(data, [25, 75])\n",
"iqr = q3 - q1\n",
"lower = q1 - 1.5 * iqr\n",
"upper = q3 + 1.5 * iqr\n",
"outliers = [x for x in data if x < lower or x > upper]\n",
"print(f'IQR: {iqr}')\n",
"print(f'Outliers: {outliers}')"],
"outputs": [{"text": "IQR: 3.25\nOutliers: [100]"}]
}
]
}
Output FB2 file (analysis.fb2):
<FictionBook>
<description>
<title-info>
<book-title>Exploratory Data Analysis
Cookbook</book-title>
</title-info>
</description>
<body>
<section>
<title>Recipe: Detecting Outliers</title>
<p>Use the IQR method to find outliers
in your data.</p>
<p>[Code]</p>
<p>import numpy as np</p>
<p>data = [12, 15, 14, 10, 100, ...]</p>
<p>q1, q3 = np.percentile(data, [25, 75])</p>
<p>iqr = q3 - q1</p>
<p>Output:</p>
<p>IQR: 3.25</p>
<p>Outliers: [100]</p>
</section>
</body>
</FictionBook>
Example 3: Tutorial Collection to FB2
Input IPYNB file (research.ipynb):
{
"cells": [
{
"cell_type": "markdown",
"source": ["# Web Scraping with Python\n",
"## Fetching a Web Page\n",
"Use the `requests` library to download HTML content."]
},
{
"cell_type": "code",
"source": ["import requests\n",
"url = 'https://example.com'\n",
"response = requests.get(url)\n",
"print(f'Status: {response.status_code}')\n",
"print(f'Content length: {len(response.text)} chars')\n",
"print(f'Title found: {\"\" in response.text}')"],
"outputs": [{"text": "Status: 200\nContent length: 1256 chars\nTitle found: True"}]
}
]
}
Output FB2 file (research.fb2):
<FictionBook>
<description>
<title-info>
<book-title>Web Scraping with Python
</book-title>
</title-info>
</description>
<body>
<section>
<title>Fetching a Web Page</title>
<p>Use the requests library to download
HTML content.</p>
<p>[Code]</p>
<p>import requests</p>
<p>url = 'https://example.com'</p>
<p>response = requests.get(url)</p>
<p>print(f'Status: {response.status_code}')</p>
<p>Output:</p>
<p>Status: 200</p>
<p>Content length: 1256 chars</p>
<p>Title found: True</p>
</section>
</body>
</FictionBook>
Frequently Asked Questions (FAQ)
Q: What is FB2 and where is it commonly used?
A: FB2 (FictionBook 2) is an XML-based ebook format that originated in Russia and is widely used in Eastern European countries. It is the primary format for many online ebook libraries and is natively supported by popular reading applications like FBReader, CoolReader, and AlReader.
Q: How does code from notebooks appear in the FB2 file?
A: Code cells are represented as pre-formatted text sections within the FB2 XML structure. While FB2 does not support syntax highlighting natively, the monospaced text presentation distinguishes code from regular narrative text in the reading application.
Q: Can I read the FB2 file on an iPhone or iPad?
A: Yes. FBReader is available for iOS and provides full FB2 support. Other iOS reading applications that support FB2 include KyBook, Marvin, and TotalReader. You can also convert FB2 to EPUB using Calibre for Apple Books compatibility.
Q: Are notebook images embedded in the FB2 file?
A: FB2 supports embedding images as Base64-encoded binary data within the XML file. Static images from notebook outputs may be included. However, interactive visualizations are not supported and are converted to text representations.
Q: Can I convert the FB2 to other ebook formats?
A: Yes. Calibre can convert FB2 to EPUB, MOBI, AZW3, PDF, and many other formats. FB2's structured XML format makes it an excellent intermediate format for multi-format ebook distribution.
Q: Does the conversion preserve notebook metadata?
A: Yes. The notebook filename and available metadata are mapped to FB2's rich metadata elements including title-info, document-info, and publish-info. This ensures the ebook is properly cataloged in reading applications.
Q: How are markdown headings converted in FB2?
A: Markdown headings become FB2 section titles. The heading hierarchy creates nested sections in the FB2 document, which reading applications use to build the table of contents for navigation.
Q: What is the difference between .fb2 and .fb2.zip extensions?
A: The .fb2.zip extension indicates a ZIP-compressed FB2 file. Since FB2 is XML text, compression can significantly reduce file size (often 60-80% smaller). Most FB2 readers can open both compressed and uncompressed variants.