Command
screenjson validate -i screenplay.json
Exit code 0 means conforming. Error messages are printed to stderr.
Strict mode for CI
screenjson validate -i screenplay.json --strict
With --strict, a non-conforming document returns exit code 1. Drop it
straight into a GitHub Action, GitLab CI job, or any shell-driven
pipeline.
Verbose output
screenjson validate -i screenplay.json --verbose
Prints the schema version used, the conformance report, and counts of objects validated.
GitHub Actions example
name: validate
on: [push, pull_request]
jobs:
schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate all ScreenJSON documents
run: |
docker run --rm -v "$PWD:/data" screenjson/cli \
validate -i /data/screenplays/*.json --strict
With your own JSON Schema validator
If you don’t want to install the CLI, any JSON Schema validator works:
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
const schema = await fetch('https://screenjson.com/schema.json').then((r) => r.json());
const doc = await fetch('./screenplay.json').then((r) => r.json());
const ajv = addFormats(new Ajv({ allErrors: true }));
const validate = ajv.compile(schema);
console.log(validate(doc) ? 'valid' : validate.errors);