fountain-py

PyPI version Python versions

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_json and rebuilds a document with from_json, backed by a versioned schema.

  • Ships a fountain command-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 pdf extra), 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

Documentation

Indices and Tables