Convert FB2 to TOML
Max file size 100mb.
FB2 vs TOML Format Comparison
| Aspect | FB2 (Source Format) | TOML (Target Format) |
|---|---|---|
| Format Overview |
FB2
FictionBook 2.0
XML-based ebook format developed in Russia. Designed specifically for fiction and literature with rich metadata support. Extremely popular in Eastern Europe and CIS countries. Stores complete book structure including chapters, annotations, and cover images in a single XML file. Ebook Format XML-Based |
TOML
Tom's Obvious Minimal Language
Human-readable configuration file format designed to map unambiguously to hash tables. Created by Tom Preston-Werner (GitHub co-founder) in 2013. Popular for configuration files in Rust, Python, and Go projects. Easy to read and write, with strong data typing and clear semantics. Configuration Plain Text |
| Technical Specifications |
Structure: XML document
Encoding: UTF-8 Format: Text-based XML Compression: Optional (ZIP as .fb2.zip) Extensions: .fb2, .fb2.zip |
Structure: Key-value pairs and tables
Encoding: UTF-8 Format: Human-readable text Compression: None Extensions: .toml |
| Syntax Examples |
FB2 uses XML structure: <FictionBook>
<description>
<title-info>
<book-title>My Book</book-title>
<author>John Doe</author>
</title-info>
</description>
<body>
<section>
<title>Chapter 1</title>
<p>Text content...</p>
</section>
</body>
</FictionBook>
|
TOML uses key-value pairs and tables: title = "My Book" author = "John Doe" [metadata] format = "book" version = "1.0" [[chapters]] number = 1 title = "Chapter 1" content = "Text content..." [settings] toc = true language = "en" |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2004 (Russia)
Current Version: FB2.1 Status: Stable, widely used Evolution: FB3 in development |
Introduced: 2013 (Tom Preston-Werner)
Current Version: TOML v1.0.0 Status: Stable specification Evolution: Mature, stable format |
| Software Support |
Calibre: Full support
FBReader: Native format Cool Reader: Full support Other: Moon+ Reader, AlReader |
Python: tomllib, toml libraries
Rust: toml, serde_toml crates Go: BurntSushi/toml package Other: JavaScript, Ruby, PHP parsers |
Why Convert FB2 to TOML?
Converting FB2 ebooks to TOML format is useful when you want to extract structured metadata and content for configuration purposes, data analysis, or integration with modern development tools. TOML's human-readable format makes it perfect for extracting book information, metadata catalogs, and structured content that can be easily parsed by applications.
FB2 (FictionBook 2) is an XML-based ebook format extremely popular in Russia and Eastern Europe. It excels at storing fiction with rich metadata including author information, cover images, annotations, and structured chapters. However, when you need to extract this metadata for cataloging, processing, or configuration purposes, FB2's XML structure can be overly complex.
TOML (Tom's Obvious Minimal Language) provides a clean, unambiguous alternative for storing structured data. Created by GitHub co-founder Tom Preston-Werner, TOML has become the standard for configuration files in Rust (Cargo.toml), Python (pyproject.toml), and many other modern projects. By converting FB2 to TOML, you can extract book metadata in a format that's both human-readable and machine-parseable.
Key Benefits of Converting FB2 to TOML:
- Metadata Extraction: Clean extraction of book information and properties
- Easy Parsing: Simple to read and process in any programming language
- Configuration Format: Ideal for storing book catalogs and settings
- Data Interchange: Easy to share structured data between applications
- Human-Readable: Easy to edit and understand without XML knowledge
- Type Safety: Strong typing for dates, numbers, booleans
- No Ambiguity: Clear semantics unlike YAML or JSON edge cases
Practical Examples
Example 1: Metadata Extraction
Input FB2 file (book.fb2):
<title-info>
<book-title>The Great Adventure</book-title>
<author>
<first-name>John</first-name>
<last-name>Smith</last-name>
</author>
<genre>sci_fi</genre>
<date>2024</date>
</title-info>
Output TOML file (book.toml):
title = "The Great Adventure" genre = "sci_fi" date = 2024 [author] first_name = "John" last_name = "Smith" full_name = "John Smith"
Example 2: Book Structure
Input FB2 chapters:
<section> <title>Chapter 1: Beginning</title> <p>First paragraph...</p> </section> <section> <title>Chapter 2: Middle</title> <p>Second paragraph...</p> </section>
Output TOML structure:
[[chapters]] number = 1 title = "Chapter 1: Beginning" content = "First paragraph..." [[chapters]] number = 2 title = "Chapter 2: Middle" content = "Second paragraph..."
Example 3: Complete Book Metadata
Input FB2 description:
<description>
<title-info>
<book-title>My Novel</book-title>
<lang>en</lang>
</title-info>
<document-info>
<program-used>FB2Editor</program-used>
</document-info>
</description>
Output TOML catalog:
[book] title = "My Novel" language = "en" format = "fb2" [document] program_used = "FB2Editor" source_format = "fb2"
Frequently Asked Questions (FAQ)
Q: What is FB2 format?
A: FB2 (FictionBook 2) is an XML-based ebook format created in Russia in 2004. It's designed for storing fiction with rich metadata including author info, genres, cover images, and structured content. FB2 is extremely popular in Eastern Europe and CIS countries, supported by readers like FBReader, Cool Reader, and Calibre.
Q: What is TOML?
A: TOML (Tom's Obvious Minimal Language) is a configuration file format created by Tom Preston-Werner in 2013. It's designed to be easy to read and write, with unambiguous semantics that map clearly to hash tables. TOML is popular for configuration files in Rust, Python, and Go projects.
Q: Why convert FB2 to TOML?
A: Converting FB2 to TOML is useful for extracting metadata, creating book catalogs, integrating with configuration systems, or processing book information in applications. TOML's simple syntax makes it easy to parse and edit compared to XML.
Q: What metadata is preserved?
A: The conversion extracts key metadata including book title, author information, publication date, genre, language, and document properties. Chapter titles and structure are also preserved. Images are typically referenced but not embedded.
Q: Can I convert TOML back to FB2?
A: TOML to FB2 conversion is technically possible but limited, as TOML is primarily for configuration data while FB2 is a complete ebook format. You would need to manually structure the TOML data and add FB2-specific formatting elements.
Q: What tools can parse TOML?
A: TOML is supported in most programming languages: Python (tomllib/toml), Rust (toml/serde_toml), Go (BurntSushi/toml), JavaScript (toml-node), Ruby (tomlrb), PHP (toml), and many others. Most text editors also support TOML syntax highlighting.
Q: How is TOML different from JSON or YAML?
A: TOML is more readable than JSON and less ambiguous than YAML. It supports comments (unlike JSON), has strong typing for dates/times, and avoids YAML's complex edge cases with whitespace. TOML is specifically designed for configuration files.
Q: What happens to images and formatting?
A: FB2 images (Base64-encoded) can be extracted and referenced in TOML with file paths. Text formatting (bold, italic) is typically simplified or stored as plain text, since TOML is a data format rather than a document format.