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

@lenml/char-card-reader

v1.1.1

Published

SillyTavern character card info reader

Readme

Char Card Reader

NPM Downloads NPM Version

A lightweight library for reading SillyTavern character card metadata from image files (PNG, JPEG, WEBP) and JSON without external dependencies.

Features

  • Supports character card specifications v1, v2, and v3
  • Extracts metadata from PNG, JPEG, WEBP images and JSON data
  • Provides conversion between different spec versions
  • Zero external dependencies
  • Works in both Node.js and browser environments

Installation

npm install @lenml/char-card-reader
# or
yarn add @lenml/char-card-reader
# or
pnpm install @lenml/char-card-reader

Usage

Basic Usage (Node.js)

import { CharacterCard } from "@lenml/char-card-reader";
import fs from "fs";

(async () => {
  // Load from image file
  const file = fs.readFileSync("./path/to/character.png");
  const card = await CharacterCard.from_file(file);

  // Or load from JSON data
  const jsonData = {
    // character data, support v1/v2/v3 format
  };
  const jsonCard = CharacterCard.from_json(jsonData);

  // Access card properties
  console.log("Character Name:", card.name);
  console.log("Description:", card.description);
  console.log("First Message:", card.first_message);

  // Convert between specs
  const v1Data = card.toSpecV1();
  const v2Data = card.toSpecV2();
  const v3Data = card.toSpecV3();
})();

Browser Usage

<script type="module">
  import { CharacterCard } from "https://esm.run/@lenml/char-card-reader";

  const fileInput = document.getElementById("character-file");

  fileInput.addEventListener("change", async (e) => {
    const file = e.target.files[0];
    if (!file) return;

    // Load from image file
    if (file.type.startsWith("image/")) {
      const arrayBuffer = await file.arrayBuffer();
      const card = await CharacterCard.from_file(arrayBuffer);
      console.log("Character Info:", card.toSpecV3());
    }
    // Or load from JSON file
    else if (file.type === "application/json") {
      const jsonText = await file.text();
      const jsonData = JSON.parse(jsonText);
      const card = CharacterCard.from_json(jsonData);
      console.log("Character Info:", card.toSpecV3());
    }
  });
</script>

API

CharacterCard Class

Static Methods

  • from_file(file: ArrayBuffer | Uint8Array): Promise<CharacterCard> - Creates a CharacterCard instance from a file
  • from_json(raw_data: CharRawData, fallback_avatar = ""): CharacterCard - Creates a CharacterCard instance from JSON data

Instance Properties

  • avatar - Character avatar URL
  • name - Character name
  • description - Character description
  • first_message - First message/opening line
  • personality - Personality description
  • scenario - Scenario context
  • alternate_greetings - Array of alternate greetings
  • tags - Array of character tags
  • And more...

Conversion Methods

  • toSpecV1() - Converts to v1 spec format
  • toSpecV2() - Converts to v2 spec format
  • toSpecV3() - Converts to v3 spec format

CharacterBook (Lorebook)

from character card

import { CharacterCard } from "@lenml/char-card-reader";
const file = fs.readFileSync("./path/to/character.png");
const card = await CharacterCard.from_file(file);
const book = card.get_book();
const entries = book.scan(card.first_message);

from json data

import { CharacterBook } from "@lenml/char-card-reader";
const json_data = {
  entries: [
    /*...*/
  ],
};
const book = CharacterBook.from_json(json_data);
const entries = book.scan("this xxoo world.");

Document

click to [Read generated document]

Specifications References

License

AGPL-3.0