FB2 File Documentation
Summary
An FB2 (FictionBook 2.0) file is an e-book stored as a single self-contained XML document, an open, DRM-free format especially popular in Russian-speaking countries. Unlike EPUB, it packs the text, metadata, table of contents and even images (base64-encoded) into one .fb2 file. Its MIME type is application/x-fictionbook+xml. Read it with Calibre or FBReader on desktop, or FBReader and Cool Reader on mobile; to use it on a Kindle or in Apple Books, convert it to EPUB with Calibre.
Technical details
| Feature | Value |
|---|---|
| Full name | FictionBook 2.0 e-book |
| File extension | .fb2 (compressed: .fb2.zip, .fbz) |
| MIME type | application/x-fictionbook+xml |
| Format type | Single XML e-book document (UTF-8) |
| Developer | FictionBook community (Dmitry Gribov et al.), Russia |
| Introduced | 2004 (FictionBook 2.0) |
| Container / base format | Plain XML (not a ZIP container, unlike EPUB) |
| Root element | <FictionBook> |
| Images | Embedded inline as base64 in <binary> elements |
| DRM | None (DRM-free by design) |
| Open standard | Yes (open community format) |
| Character encoding | UTF-8 (declared in the XML prolog) |
| Magic number | 3C 3F 78 6D 6C (<?xml); compressed variants start 50 4B 03 04 (ZIP) |
| Byte order | N/A (text) |
| Best reader / converter | Calibre; FBReader for native reading |
| Related extensions | .epub, .mobi, .azw3, .fbz, .pdf |
| Specification | fictionbook.org description |
What is an FB2 file?
FB2, short for FictionBook 2.0, is an open e-book format introduced in 2004 by the FictionBook community (originated by Dmitry Gribov and collaborators in Russia). It stores an entire book as a single XML file. That is the defining trait. Where EPUB and MOBI are ZIP containers holding many separate files, an .fb2 keeps everything, structured text, metadata, the table of contents, and even images, inside one self-contained, human-readable XML document with UTF-8 encoding.
The format describes a book’s logical structure (its title, sections, epigraphs, footnotes and emphasis) rather than its page layout, so the text reflows cleanly to any screen size. The format is open and DRM-free by design, which is a large part of its appeal: any reader can open any FB2, and because it is just XML, users can fix a typo or correct the author metadata by hand. Its MIME type is application/x-fictionbook+xml.
One XML document instead of a ZIP container
The architectural choice that separates FB2 from every mainstream e-book format is that it is not a container. Open an .fb2 and the first bytes are the XML prolog, 3C 3F 78 6D 6C, the ASCII <?xml, followed by a <FictionBook> root element. There is no ZIP central directory, no separate spine file, no manifest of parts. The whole book, cover included, is one stream of well-formed XML.
That has consequences. It makes an FB2 trivially inspectable and editable in any text editor, and it means the file is valid or it is not: a single unclosed tag can stop a reader parsing it, exactly as with any XML. It also means images have to be carried inline rather than sitting as separate files beside the text, which is why FB2 uses base64 (covered below). Because the text and its markup dominate, uncompressed FB2 files are larger than they need to be for transport, which is why books are often distributed compressed as .fb2.zip or .fbz.
The FictionBook root and its four children
Below the <FictionBook> root, the schema allows four kinds of child element, in order: an optional <stylesheet>, a <description>, one or more <body> elements, and zero or more <binary> elements.
<?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">
<stylesheet type="text/css"> ... optional inline CSS ... </stylesheet>
<description> ... book metadata ... </description>
<body> ... the readable book ... </body>
<body name="notes"> ... footnotes ... </body>
<binary id="cover.jpg" content-type="image/jpeg">/9j/4AAQSk...</binary>
</FictionBook>
The <stylesheet> element is defined but rarely used, because reading programs generally apply their own typography rather than the book’s. FB2 is structure-first, not layout-first, so most books omit it entirely. The three elements that carry the real content are the description, the body, and the binaries.
The description block: metadata, title-info and document-info
The <description> element holds the book’s metadata, and it is more structured than a simple key-value list. It is divided into sub-blocks. <title-info> carries the reader-facing facts: genre, author (as separate first-name, last-name and middle-name elements, not a single string), the book title, an optional annotation, the language, the series it belongs to, and a reference to the cover image. <document-info> records who produced the FB2 file itself, the program used, the creation and version dates, and the source. <publish-info> describes the paper edition the file was made from, including publisher, city, year and ISBN.
Splitting an author into separate name elements, rather than one free-text field, is deliberate: it lets a library sort thousands of books by surname reliably, which is one reason FB2 works well for the large free-book collections that popularised it. The cover is not stored in the description; the description only references it by id, and the image data lives in a <binary> element at the end of the file.
The body: sections, titles and footnote bodies
The <body> element is the book itself. It nests <section> elements, which can nest further to any depth, giving chapters and sub-chapters. A section holds a <title>, then content: paragraphs (<p>), epigraphs, poems (<poem> with <stanza> and <v> verse lines), citations, and inline markup such as <emphasis> and <strong>. The section hierarchy is what a reader turns into a navigable table of contents; there is no separate TOC file because the nesting is the TOC.
A crucial detail is that a document may contain more than one <body>. The first body is the one shown to the reader by default. Additional bodies hold content that does not belong in the main flow, most importantly footnotes and endnotes, conventionally in a body with name="notes". A footnote marker in the main text is a hyperlink (using the XLink namespace) that points at an element by id inside the notes body, so tapping the marker jumps to the note. This split keeps notes out of the reading flow while still carrying them in the same file.
The binary element: base64 images inside the XML
Because an FB2 is a single file and XML cannot hold raw binary bytes, every image is encoded as base64 text and placed in a <binary> element near the end of the document. Each such element must carry two attributes: an id (the name other parts of the book reference, for example cover.jpg) and a content-type (the MIME type, typically image/jpeg or image/png).
<binary id="fig1.png" content-type="image/png">
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lE
QVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==
</binary>
Elsewhere in the book, an <image> element references that binary by its id through an XLink href such as href="#fig1.png". Base64 inflates image data by roughly a third, which is the price of keeping everything in one XML file, and it is another reason distributors zip FB2 files for download. The cover works the same way: <title-info> names the cover image, and the actual pixels sit in a matching <binary>.
FBZ and FB2.ZIP: the compressed variants
Because the XML plus base64 images make an FB2 bulky, books are frequently shipped compressed. A .fb2.zip or .fbz is simply an FB2 placed inside a ZIP archive, so it starts with the ZIP signature 50 4B 03 04 (PK) rather than the XML prolog. There is exactly one .fb2 inside. “Converting” between the two is just zipping or unzipping: rename an .fbz to .zip and extract to recover the .fb2. Most FB2 readers, including Calibre, FBReader and Cool Reader, open the compressed variants directly without any manual step.
Reading FB2 and moving it to other devices
Native FB2 readers exist on every platform: Calibre and FBReader on Windows, macOS and Linux; FBReader, Cool Reader and PocketBook on Android; FBReader and KyBook on iOS. Because the format is plain XML, any of them opens a file directly, and you can also open one in a text editor to inspect it before reading. The friction appears only with the mainstream ecosystems: Amazon Kindle, Apple Books and Google Play Books do not read FB2 natively. The standard workaround is to convert to EPUB, which nearly every device reads, using Calibre. Calibre’s FB2-to-EPUB conversion preserves the section structure, the footnote bodies and the embedded base64 images, because both formats describe structure rather than fixed pages. For a Kindle you can then use Send to Kindle, which has accepted EPUB since 2022.
Frequently asked questions
Why does an FB2 file have more than one body?
The first <body> is the readable book. Extra bodies, conventionally name="notes", hold footnotes and endnotes that should not appear in the main flow. Footnote markers in the text are XLink hyperlinks that jump to elements inside the notes body, keeping the notes in the same single file without cluttering the reading order.
How are images stored if FB2 is a single file?
Each image is base64-encoded and placed in a <binary> element carrying an id and a content-type. The book references it by id through an XLink href. This keeps the whole book, cover and illustrations included, inside one XML document, at the cost of roughly a third more size from base64.
Can I edit an FB2 file by hand?
Yes. Because it is plain XML you can open it in a text editor or Calibre’s editor to fix the title, author or a typo. Keep it well-formed (matching tags) and save as UTF-8 so readers still parse it.
References
- FictionBook — FB2 format description (official wiki)
- Calibre — e-book manager and converter
- FBReader — native FictionBook reader
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.