Skip to content
screenjson

Schema & data

Store ScreenJSON in MongoDB

Write ScreenJSON documents directly into a MongoDB collection from the CLI, or index them programmatically.

Last updated January 2026

From the CLI

screenjson convert -i screenplay.fdx \
  --db mongodb \
  --db-host mongodb://localhost:27017 \
  --db-collection screenplays

With environment variables

export SCREENJSON_DB_TYPE=mongodb
export SCREENJSON_DB_HOST=mongodb://mongo:27017
export SCREENJSON_DB_COLLECTION=screenplays
screenjson convert -i screenplay.fdx

Programmatically

import { MongoClient } from 'mongodb';

const client = await MongoClient.connect('mongodb://localhost:27017');
const col = client.db('scripts').collection('screenplays');

const doc = JSON.parse(fs.readFileSync('screenplay.json', 'utf8'));

await col.updateOne(
  { _id: doc.id },                // use the ScreenJSON uuid as primary key
  { $set: doc },
  { upsert: true },
);

Useful indexes

await col.createIndex({ 'title.en': 'text', 'logline.en': 'text' });
await col.createIndex({ 'characters.id': 1 });
await col.createIndex({ 'document.scenes.heading.context': 1 });
await col.createIndex({ genre: 1, themes: 1 });

Next