fountain-py¶
fountain-py is a Python library for parsing and rendering Fountain, the plain-text screenwriting format. It turns a Fountain script into structured Python objects you can analyze, and renders it back out as HTML, plain text, Fountain, Final Draft (FDX), PDF, or JSON.
Features¶
Parses the Fountain syntax: scene headings, action, character cues, dialogue, dual dialogue, parentheticals, lyrics, transitions, centered text, sections, synopses, notes, and inline emphasis.
Extracts characters, scenes, and statistics from a parsed script.
Renders to HTML (fragment, standalone page, or raw CSS), plain text, Final Draft (FDX), or PDF, and round-trips back to clean Fountain.
Serializes to JSON with
to_jsonand rebuilds a document withfrom_json, backed by a versioned schema.Ships a
fountaincommand-line tool for validating and rendering scripts without writing any Python.Reports parse problems (unclosed boneyard or notes, orphaned character cues) through a validation API.
Pure Python core with no runtime dependencies (PDF export is an optional
pdfextra), fully type-hinted.
Quick Example¶
from fountain import FountainParser
script = """Title: The Coffee Shop Connection
Author: Jane Doe
INT. COFFEE SHOP - DAY
ALICE sits at a corner table, staring at her laptop.
ALICE
Come on, inspiration... where are you?
"""
document = FountainParser().parse(script)
print(document.metadata["title"]) # The Coffee Shop Connection
print(document.get_characters()) # ['ALICE']
# Render a standalone HTML file with embedded CSS
with open("coffee_shop.html", "w", encoding="utf-8") as f:
f.write(document.to_html())
Start Here¶
Installation: install with
pip install fountain-py.Quick Start: parse a screenplay and render it to HTML in minutes.
What Is Fountain?: the format, and what fountain-py does with it.
How fountain-py Works: the parse, structure, and render pipeline.
API Reference: the class and method reference.
Project Links¶
GitHub Repository: github.com/MasonEgger/fountain-py
Documentation: masonegger.github.io/fountain-py
Issue Tracker: Report bugs or request features
Documentation¶
Getting Started
How-to Guides
- Validate a Fountain File
- Render a Screenplay to an HTML File
- Embed a Screenplay in a Web Page
- Style the HTML Output
- Round-Trip Back to Clean Fountain
- Export a Screenplay to JSON
- Export a Screenplay to Plain Text
- Export a Screenplay to Final Draft (.fdx)
- Export a Screenplay to PDF
- Use the Command Line
- Extract a Character’s Dialogue
Explanation
Reference
Contributing