Skip to content
screenjson

JS · SDK

screenjson-ui

A framework-agnostic JavaScript package that renders ScreenJSON documents as Warner Bros / Final Draft-style screenplays. Dark/light, multi-language, virtual scrolling, encryption support.

screenjson-ui hero image
Repository public

What it is

screenjson-ui is an embeddable document viewer for ScreenJSON files. It renders a ScreenJSON document as a pixel-accurate, Warner Bros / Final Draft- style screenplay in the browser: Courier Prime at 12pt, correct margins for action, dialogue, cues, parentheticals, and transitions, scene numbers in the margin if you want them, page numbers top-right, dark and light themes.

It is framework-agnostic. Install it from npm, import it into a React or Vue app, or use the native Svelte component in a Svelte/SvelteKit codebase.

Features

  • PDF-style rendering. Warner Bros / Final Draft margins, Courier Prime 12pt, 60 lines per page.
  • Dark & light themes with persistence.
  • Multi-language — a ScreenJSON file can carry translations of every text run; switch on the fly.
  • Virtual scrolling for 300+ page documents without jank.
  • Responsive — works from 400px phones to 1200px+ desktops.
  • Encrypted content — supply a password and encrypted runs decrypt in-browser.
  • Bookmarks & notes — stored in localStorage per document.
  • Metadata panel — character list, scene index, SFX/VFX/props/wardrobe breakdowns.
  • Package-first — published as @screenjson/ui for standard npm workflows.

Install

NPM

npm install @screenjson/ui

Use

JavaScript API

import ScreenJSONUI from '@screenjson/ui';

const viewer = new ScreenJSONUI({
  element: 'viewer',          // element id or HTMLElement
  src: '/screenplay.json',    // URL — or pass `document` for inline JSON
  theme: 'dark',
  numbered: true,
  virtual: true,
  onLoad:       (doc)  => console.log('loaded', doc.title),
  onPageChange: (page) => console.log('page', page),
});

Browser ESM

<link rel="stylesheet" href="https://unpkg.com/@screenjson/ui/dist/ui.css" />
<script type="module">
  import ScreenJSONUI from 'https://unpkg.com/@screenjson/ui/dist/screenjson-ui.js';
  new ScreenJSONUI({ element: 'viewer', src: '/screenplay.json', theme: 'dark' });
</script>

Svelte

<script lang="ts">
  import { ScreenJSONViewer } from '@screenjson/ui';
  import type { ScreenJSONDocument } from '@screenjson/ui';

  export let document: ScreenJSONDocument;
</script>

<ScreenJSONViewer {document} theme="light" numbered />

Configuration

OptionTypeDefaultDescription
elementstring | HTMLElementrequiredTarget container
srcstringURL to load ScreenJSON from
documentScreenJSONDocumentPre-loaded document object
theme'light' | 'dark''light'Initial theme
zoomnumber10.5 – 2
langstringdocument defaultBCP 47 tag for rendered text
pagenumber1Initial page
numberedbooleanfalseShow scene numbers in margins
paginatedbooleantrueShow page numbers
cornerstring'top-right'Menu button position
virtualbooleanfalseVirtualised scrolling
passwordstringDecrypt password for encrypted content
onLoadfunctionCalled when the document loads
onPageChangefunctionCalled on page change
onErrorfunctionCalled on error

Formatting standards

The viewer targets the Warner Bros / Final Draft convention used by every major studio:

  • Paper: US Letter (8.5” × 11”)
  • Font: Courier Prime, 12pt
  • Lines/page: 60 maximum
  • Margins: Action 1.7”L / 1.1”R · Dialogue 2.7”L / 2.4”R · Character 4.1”L · Parenthetical 3.4”L / 3.1”R · Transition 6.0”L

If you need A4 or a different font stack, both are configurable at render time.

Browser support

Chrome 90+ · Firefox 90+ · Safari 14+ · Edge 90+.

When to use it

Use screenjson-ui when you want to show a screenplay inside your own product: a writers’ room UI, a producer dashboard, a studio archive, an e-reader, a review tool, a marketing site. It’s the fastest path from “I have a ScreenJSON file on an object store” to “our users can read it”.

Pair with screenjson-cli or Greenlight to produce the JSON in the first place.

License

MIT. The schema it renders is also open: see the specification.

Next