Convert FB2 to YAML

Drag and drop files here or click to select.
Max file size 100mb.
Uploading progress:

FB2 vs YAML Format Comparison

Aspect FB2 (Source Format) YAML (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
YAML
YAML Ain't Markup Language

Human-friendly data serialization format commonly used for configuration files, data exchange, and structured content. Features minimal syntax, excellent readability, and wide language support. Popular in DevOps, CI/CD pipelines (GitHub Actions, Docker Compose), and application configs.

Data Format 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: Indentation-based hierarchy
Encoding: UTF-8
Format: Plain text key-value pairs
Compression: None
Extensions: .yaml, .yml
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>

YAML uses indentation and colons:

book:
  title: "My Book"
  author: "John Doe"
  chapters:
    - title: "Chapter 1"
      content: "Text content..."
      paragraphs:
        - "First paragraph"
        - "Second paragraph"
  metadata:
    year: 2024
    genre: fiction
Content Support
  • Rich book metadata (author, title, genre)
  • Cover images (embedded Base64)
  • Chapters and sections
  • Annotations and epigraphs
  • Footnotes and comments
  • Poems and citations
  • Tables (basic)
  • Internal links
  • Multiple bodies (main + notes)
  • Nested data structures (maps, lists)
  • Key-value pairs
  • Multi-line strings
  • Comments (# prefix)
  • Arrays and sequences
  • Anchors and aliases (references)
  • Multiple data types (strings, numbers, booleans)
  • Null values
  • Block and flow styles
Advantages
  • Excellent for fiction/literature
  • Rich metadata support
  • Single file contains everything
  • Widely supported by ebook readers
  • Free and open format
  • Good compression ratio (.fb2.zip)
  • Extremely human-readable
  • Minimal syntax (no brackets/quotes)
  • Easy to edit manually
  • Wide programming language support
  • Perfect for configuration files
  • Supports comments
  • Version control friendly
Disadvantages
  • Limited outside Eastern Europe
  • Not supported by Amazon Kindle
  • Complex XML structure
  • Not ideal for technical docs
  • Manual editing is difficult
  • Indentation-sensitive (can cause errors)
  • Not ideal for large datasets
  • Parsing can be slower than JSON
  • Multiple valid representations
  • Tab characters not allowed
  • Complex specification edge cases
Common Uses
  • Fiction and literature ebooks
  • Digital libraries (Flibusta, etc.)
  • Ebook distribution in CIS
  • Personal ebook collections
  • Ebook reader apps
  • Configuration files (Docker, Kubernetes)
  • CI/CD pipelines (GitHub Actions, GitLab CI)
  • Application settings
  • Data serialization and exchange
  • API responses
  • Infrastructure as Code (Ansible, Terraform)
Best For
  • Reading fiction on devices
  • Ebook library management
  • Sharing books in CIS region
  • Structured fiction content
  • Configuration management
  • Data extraction and analysis
  • Human-editable data files
  • Structured content representation
Version History
Introduced: 2004 (Russia)
Current Version: FB2.1
Status: Stable, widely used
Evolution: FB3 in development
Introduced: 2001 (Clark Evans)
Current Version: YAML 1.2 (2021)
Status: Stable, active development
Evolution: Continuous refinement
Software Support
Calibre: Full support
FBReader: Native format
Cool Reader: Full support
Other: Moon+ Reader, AlReader
Python: PyYAML, ruamel.yaml
JavaScript: js-yaml, yaml (npm)
Ruby: Psych (built-in)
Other: Go, Java, PHP, .NET libraries

Why Convert FB2 to YAML?

Converting FB2 ebooks to YAML format is useful for data extraction, content analysis, and structured data processing. YAML's human-readable format makes it ideal for extracting book metadata, analyzing content structure, or feeding ebook data into applications and scripts. Unlike XML, YAML's minimal syntax makes it easy to read and edit.

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, FB2's XML structure can be verbose and difficult to parse manually, making data extraction and analysis challenging.

YAML provides a clean, readable alternative for representing structured data. Originally created as "YAML Ain't Markup Language," it has become the de facto standard for configuration files in modern DevOps tools like Docker, Kubernetes, and GitHub Actions. By converting FB2 to YAML, you can easily extract book metadata, analyze content hierarchy, or integrate ebook data with automation workflows.

Key Benefits of Converting FB2 to YAML:

  • Data Extraction: Easily extract metadata and content structure
  • Human Readable: Minimal syntax makes data easy to understand
  • Easy Editing: Modify data without XML tag complexity
  • Programming Integration: Parse with any major language
  • Content Analysis: Analyze book structure and statistics
  • Version Control: Track changes efficiently with Git
  • Configuration Format: Use book data in applications

Practical Examples

Example 1: Book Chapter Conversion

Input FB2 file (book.fb2):

<section>
  <title>Chapter 1: The Beginning</title>
  <p>It was a dark and stormy night.</p>
  <p>The wind howled through the trees.</p>
  <emphasis>Important text</emphasis>
</section>

Output YAML file (book.yaml):

chapter:
  title: "Chapter 1: The Beginning"
  paragraphs:
    - "It was a dark and stormy night."
    - "The wind howled through the trees."
  emphasis:
    - "Important text"

Example 2: Metadata Extraction

Input FB2 metadata:

<title-info>
  <book-title>The Great Adventure</book-title>
  <author>
    <first-name>John</first-name>
    <last-name>Smith</last-name>
  </author>
  <date>2024</date>
</title-info>

Output YAML:

metadata:
  title: "The Great Adventure"
  author:
    first_name: "John"
    last_name: "Smith"
  date: 2024
  genre: fiction

Example 3: Structured Content

Input FB2 with annotations:

<annotation>
  <p>This book tells the story of...</p>
</annotation>
<epigraph>
  <p>"To be or not to be"</p>
  <text-author>Shakespeare</text-author>
</epigraph>

Output YAML:

book:
  annotation: "This book tells the story of..."
  epigraph:
    text: "To be or not to be"
    author: "Shakespeare"

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 YAML?

A: YAML (YAML Ain't Markup Language) is a human-friendly data serialization format. It uses minimal syntax with indentation-based structure, making it easy to read and write. YAML is widely used for configuration files (Docker, Kubernetes, CI/CD pipelines) and data exchange between programming languages.

Q: Will book structure be preserved?

A: Yes! FB2's hierarchical structure (sections, chapters, metadata) is converted to nested YAML maps and lists. The conversion preserves the document hierarchy, making it easy to navigate and analyze the book's structure programmatically.

Q: What happens to images in FB2?

A: FB2 stores images as Base64-encoded data. During conversion, images can be extracted and saved as separate files, with the YAML file containing image metadata (filename, type, size). Alternatively, Base64 data can be preserved in the YAML for complete data representation.

Q: Can I convert YAML back to FB2?

A: While theoretically possible, converting YAML back to FB2 would require custom scripting to reconstruct the XML structure. YAML is primarily a data format, not an ebook format, so direct conversion tools are uncommon. The YAML output is best used for data analysis rather than ebook recreation.

Q: What programming languages support YAML?

A: YAML is supported by virtually all major programming languages. Popular libraries include PyYAML (Python), js-yaml (JavaScript), go-yaml (Go), SnakeYAML (Java), yaml (Ruby gem), and YamlDotNet (.NET). This makes it easy to process converted FB2 data in any language.

Q: How do I edit YAML files?

A: YAML files can be edited in any text editor. Use 2 spaces for indentation (not tabs), ensure proper key-value syntax (key: value), and use quotes for strings with special characters. Many editors like VS Code, Sublime Text, and Vim provide YAML syntax highlighting and validation.

Q: What can I do with FB2 data in YAML format?

A: YAML format enables data analysis, content extraction, metadata processing, and automation. You can analyze book statistics, extract author information, process chapters programmatically, integrate with databases, or use the data in web applications and scripts.