← Open Source
open-spaced-repetition

ts-fsrs (Open on GitHub)

ts-fsrs is a versatile package written in TypeScript that supports ES modules, CommonJS, and UMD.

TypeScript
Momentum
+2stars in 24 hours+0.2%
904
Stars
77
Forks
+8
This week
22
Contributors
Created 2023-03-05 · Updated 2026-12-04 · #3753 today
Top developers
ishiko732Luc-Mcgrady2Lavine
README

Introduction | 简体中文 |はじめに


ts-fsrs

ts-fsrs is a TypeScript toolkit for building spaced repetition systems with FSRS.

ts-fsrs-v6.mp4

Packages

This repository contains two main packages:

Package Description Supported FSRS Versions Package Version Downloads
ts-fsrs the scheduler for review flows
@open-spaced-repetition/binding the optimizer for parameter training and CSV conversion

Installation

ts-fsrs v6 and @open-spaced-repetition/binding require Node.js >=24.0.0.

pnpm add ts-fsrs

If you also need parameter optimization from review logs:

pnpm add @open-spaced-repetition/binding

Basic Usage

Use DefaultScheduler() to schedule reviews with ts-fsrs v6. It defaults to FSRS-7; the library version and the FSRS model version are independent.

import { DefaultScheduler, Rating } from 'ts-fsrs'

const now = new Date('2026-01-01T00:00:00.000Z')
const scheduler = await DefaultScheduler()
const card = scheduler.newCard({ now })

// Preview all four possible outcomes before the user answers.
const preview = scheduler.preview({ card, now })
for (const { grade, card: previewCard, revlog } of preview) {
  console.log(grade, previewCard, revlog)
}

// Apply the final rating after the user has already answered.
const result = scheduler.review({ card, grade: Rating.Good, now })

console.log(result.card)
console.log(result.revlog)

Use @open-spaced-repetition/binding when you want to train FSRS parameters from review logs. For CSV conversion, timezone handling, browser/WASI setup, and training examples, see packages/binding/README.md.

More Documentation

For detailed usage, advanced examples, browser/WASI setup, and API notes:

Examples

Other Implementations

FSRS is also available in other languages and ecosystems:

Contribute

For how to setup a local development eniroment, how to set up a Dev Container, and contribution guidelines, see CONTRIBUTING.md.

Nearby in the ranking

AI Rank for iPhone

Follow AI model rankings

Download on the App Store