FB2 (FictionBook 2)
| Full name | FictionBook 2 |
|---|---|
| Extensions | .fb2; zipped: .fb2.zip, .fbz |
| MIME type | application/x-fictionbook+xml |
| Type | e-book, reflowable; a single XML file with images embedded as Base64 |
| Starts with | <?xml (sometimes after a UTF-8 BOM), root element <FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"> |
| Specification | FictionBook 2.1 XML schema |
| Maintained by | community; schema published by Gribuser |
| License | open, BSD-licensed schema |
FictionBook 2 (FB2) stores a whole book in one XML file: metadata, the text marked up by structure (sections, titles, paragraphs, poems, epigraphs, notes) and the images as Base64 data. It describes what the text is, not how it looks: there is no layout or CSS, so every reader applies its own formatting. FB2 is the dominant e-book format in Russian-speaking countries and is widely supported by e-reader apps and devices (PocketBook, ONYX BOOX, KOReader, FBReader).
Because it’s plain XML with a fixed schema, FB2 is easy to generate, validate and convert. Large online libraries distribute books as .fb2.zip: a ZIP archive containing one .fb2 file, which cuts the size by 3 to 4 times.
When to use FB2#
- Use for text-centered books (fiction, non-fiction without complex layout) when your readers use FB2-capable apps or devices.
- Use when you need a simple, single-file, schema-validated format for archiving or converting book text.
- Avoid for books that need precise layout, tables with styling, fonts or interactivity: use EPUB.
- Avoid when the audience reads on Kindle or Apple Books, which don’t open FB2: convert to EPUB or AZW3.
File structure#
<?xml version="1.0" encoding="UTF-8"?>
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"
xmlns:l="http://www.w3.org/1999/xlink">
<description>
<title-info>
<genre>sf</genre>
<author><first-name>Jane</first-name><last-name>Doe</last-name></author>
<book-title>My Book</book-title>
<annotation><p>A short description.</p></annotation>
<date value="2026-01-15">2026</date>
<coverpage><image l:href="#cover.jpg"/></coverpage>
<lang>en</lang>
<sequence name="My Series" number="1"/>
</title-info>
<document-info>
<author><nickname>converter</nickname></author>
<program-used>My Tool 1.0</program-used>
<date value="2026-01-15">2026-01-15</date>
<id>6f1c2a3b-4d5e-4f60-8a7b-9c0d1e2f3a4b</id>
<version>1.0</version>
</document-info>
<publish-info>
<publisher>My Press</publisher>
<year>2026</year>
<isbn>978-0-00-000000-0</isbn>
</publish-info>
</description>
<body>
<title><p>My Book</p></title>
<section>
<title><p>Chapter 1</p></title>
<epigraph><p>An epigraph.</p><text-author>Someone</text-author></epigraph>
<p>First paragraph with <emphasis>italic</emphasis> and <strong>bold</strong> text.<a l:href="#n1" type="note">[1]</a></p>
<empty-line/>
<image l:href="#pic1.png"/>
</section>
</body>
<body name="notes">
<section id="n1"><title><p>1</p></title><p>The footnote text.</p></section>
</body>
<binary id="cover.jpg" content-type="image/jpeg">/9j/4AAQSkZJRgABAQ...</binary>
<binary id="pic1.png" content-type="image/png">iVBORw0KGgoAAAANSUhEUg...</binary>
</FictionBook>
Top-level elements#
| Element | Count | Purpose |
|---|---|---|
stylesheet |
0+ | optional CSS-like styles for named style elements; most readers ignore it |
description |
1 | metadata |
body |
1+ | the main text; extra bodies with name="notes" or name="comments" hold footnotes and endnotes |
binary |
0+ | Base64-encoded images (JPEG, PNG) with an id and content-type |
description#
| Element | Purpose |
|---|---|
title-info |
required: genre (one or more, from a fixed list such as sf, detective, prose_classic, nonf_biography), author, book-title, annotation, keywords, date, coverpage, lang, src-lang, translator, sequence (series name and number) |
src-title-info |
the same fields for the original book, for translations |
document-info |
required: who made this file, with which program, src-url, src-ocr, a unique id, version and history |
publish-info |
the printed edition: book-name, publisher, city, year, isbn, sequence |
custom-info |
free-form key/value data (info-type attribute) |
An author has first-name, middle-name, last-name, nickname, home-page, email and id.
body content#
| Element | Meaning |
|---|---|
section |
chapter or part; sections nest. Contains a title, epigraph, image, annotation, then text or child sections |
title, subtitle |
headings; title holds one or more p |
p |
paragraph |
empty-line |
vertical space |
poem, stanza, v |
poetry: stanzas of verse lines |
cite, text-author |
quotation and its author |
epigraph |
epigraph at the start of a section or the book |
table, tr, th, td |
simple tables (FB2.1) |
image |
picture referencing a binary by l:href="#id" |
Inline markup: strong, emphasis, strikethrough, sub, sup, code, style (named style), and a l:href="..." for links; type="note" marks a footnote link to a section in the notes body.
Encoding and validation#
The XML declaration gives the encoding: modern files use UTF-8, but many older Russian files are in windows-1251, so a parser must honor the declaration instead of assuming UTF-8. The official schema (FictionBook.xsd with FictionBookGenres.xsd, FictionBookLinks.xsd, FictionBookLang.xsd) validates a file, but many files found online are not fully valid; robust readers parse leniently.
FB2.ZIP and FBZ#
.fb2.zip and .fbz are ordinary ZIP archives (usually DEFLATE) that contain a single .fb2 file. Readers that support FB2 generally open them directly. To process one, unzip it and read the .fb2 inside.
Converting#
- FB2 to EPUB or AZW3:
ebook-convert book.fb2 book.epubwith Calibre, or fb2cng, a dedicated converter to EPUB 2/3, KEPUB and Kindle formats. - EPUB to FB2:
ebook-convert book.epub book.fb2(Calibre has an FB2 output plugin). - FB2 to PDF:
mutool convert -o book.pdf book.fb2(MuPDF). - Edit: FictionBook Editor (Windows) edits FB2 files visually and validates them against the schema.
Specifications and documentation#
- FictionBook 2.1 schema on GitHub: the official XSD files (
FictionBook.xsd, genres, links, languages) - FB2 on the MobileRead wiki: overview of the format and supporting software
- FictionBook on Wikipedia
- FictionBook 3 on GitHub: the successor format (a ZIP package with XML), rarely used
Software that opens FB2 files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; .fb2, .fb2z, .fbz | |||
| Calibre | ✓ | ✓ | ✓ | view, convert | free, open source; converts FB2 to and from EPUB, AZW3, PDF | |
| FBReader | ✓ | ✓ | ✓ | view | free and paid versions; FB2 and FB2.ZIP. Also on Android and iOS | |
| KOReader | ✓ | view | free, open source; runs on Kindle, Kobo and PocketBook e-readers. Also on Android | |||
| Foliate | ✓ | view | free, open source | |||
| Okular | ✓ | ✓ | view | free, open source document viewer | ||
| CoolReader | ✓ | ✓ | view | free, open source. Also on Android | ||
| Moon+ Reader | view | free with paid Pro version. Also on Android | ||||
| ReadEra | view | free. Also on Android and iOS | ||||
| PocketBook Reader | view | free; PocketBook e-readers open FB2 natively. Also on Android and iOS | ||||
| FictionBook Editor | ✓ | view, edit, create | free, open source FB2 editor and validator | |||
| fb2cng | ✓ | ✓ | ✓ | convert | free, open source; FB2 to EPUB, KEPUB, AZW3, KFX |
Libraries#
Open-source libraries that read and write FB2. See all FB2 libraries for a comparison.
| C/C++ | MuPDF |
|---|---|
| C# | Fb2.Document, FB2Library |
| Python | FB2, PyMuPDF |
| Rust | fb2 |
| PHP | PHP eBook |
Related formats#
- EPUB: the international e-book standard; richer layout, CSS and fonts
- MOBI / AZW3: Kindle formats; FB2 converts to AZW3 for Kindle devices
- ZIP: the container of
.fb2.zipand.fbz - TXT: plain text, the usual source for simple FB2 conversions