npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

scrivener-parser

v0.1.0

Published

TypeScript parser for Scrivener .scriv projects — binder, RTF content, metadata, compile settings, snapshots.

Readme

scrivener-parser

Unofficial TypeScript parser for Scrivener .scriv projects.

This is an independent implementation, not affiliated with or endorsed by Literature & Latte.
Based on the Scrivener File Format Specification — Scrivener Version 3.0, File Format Version 2.0 (23 January 2018).

Parses a .scriv project directory and exposes its contents as plain JavaScript structures:

  • Binder tree (documents, folders, hierarchy)
  • RTF document content (plain text, style spans, annotations, footnotes, tables, images)
  • Project metadata (labels, statuses, section types, custom fields, collections)
  • Compile settings and formats
  • Snapshots
  • Project resources (styles, search index)

Installation

npm install scrivener-parser

Usage

import { parseScrivenerProject } from 'scrivener-parser';
import { loadDirectoryAsArchive } from 'scrivener-parser/archive/node';

const archive = await loadDirectoryAsArchive('./my-project.scriv');
const project = parseScrivenerProject(archive, {
  decodeRtf: true,
  loadSnapshots: true,
});

console.log(project.info.title);
console.log(project.binder.length, 'root items');
console.log(Object.keys(project.documents).length, 'documents');

The loadDirectoryAsArchive helper is Node.js / CLI only. In a browser context, construct a ScrivenerArchive directly from File or FileSystemDirectoryHandle entries.

API

parseScrivenerProject(archive, options?)

Returns a ParsedScrivenerProject with the following fields:

| Field | Description | |---|---| | info | Project title, identifier, and version | | binder | Binder tree (ScrivenerBinderNode[]) | | documents | Document content keyed by UUID | | metadata | Labels, statuses, section types, custom metadata, collections | | settings | Compile settings, project preferences, UI state | | compileFormats | Compile format definitions | | resources | Styles, search index, checksums | | snapshots | Snapshots keyed by document UUID | | stats | Writing history and word count targets | | compilePlan | Resolved compile layout per binder node |

Parser options

{
  decodeRtf?: boolean;            // Parse RTF content (default: false)
  loadSnapshots?: boolean;        // Load snapshot files
  includeBinaryAssets?: boolean;  // Include raw binary data (icons, images)
  extractStyleSpans?: boolean;    // Extract style span positions
  extractInlineAnnotations?: boolean;
  extractLinkedImages?: boolean;
  extractEmbeddedImages?: boolean;
  extractHyperlinks?: boolean;
  extractBookmarks?: boolean;
  extractFields?: boolean;
  extractTables?: boolean;
  extractPlaceholders?: boolean;  // Collect compile placeholders used
  computeTextCounts?: boolean;    // Word and character counts
  normalizeBinderSections?: boolean;
  attachBinderMetaToDocs?: boolean;
}

Exports

| Entry point | Contents | |---|---| | scrivener-parser | Parser, types, and query utilities | | scrivener-parser/archive/node | Node.js directory loader |

Examples

The examples/ directory contains ready-to-run scripts:

  • inspect-sample.ts — Print a project summary (binder, documents, labels)
  • export-writing-history.ts — Export writing statistics to CSV
  • filter-custom-metadata.ts — Extract binder nodes by custom metadata field
pnpm tsx examples/inspect-sample.ts path/to/project.scriv
pnpm tsx examples/export-writing-history.ts path/to/project.scriv --out history.csv
pnpm tsx examples/filter-custom-metadata.ts path/to/project.scriv --field date

Development

pnpm test        # Run test suite
pnpm run lint    # Type-check
pnpm run build   # Build dist/

The integration test in test/tutorial-sample.test.ts requires the Scrivener Tutorial project at sample/Tutorial.scriv. Copy your Scrivener Tutorial there to enable it; all other tests use self-contained synthetic fixtures.

License

GPL-3.0-or-later — see LICENSE.