An isomorphic TypeScript library of
utility functions for parsing and interacting with
twtxt.txt files.
These functions include:
This library can be installed several different ways:
twtxt-lib.js file, either by
downloading it from the
git
repo, the
website, or doing a
git clone https://git.itsericwoodward.com/eric/twtxt-lib.git
and pulling it out of the dist-browser folder.
import { hashTwt, loadAndParseTwtxtFile } from "./twtxt-lib.js";
import { hashTwt, loadAndParseTwtxtFile } from "twtxt-lib";
Use the tabs to learn more.
Example parsed file from
/twtxt-demos/demo-hipster-twtxt.txt :
Example files generated with Hipster Ipsum, Pirate Ipsum, a different Pirate Ipsum, and Sagan Ipsum.
Copyright © 2026 Eric Woodward, released under the MIT License.
A function that takes the constituent parts of a “twt” and generates an extension-compatible hash for it.
Version 0.10.0 and above includes support for V2 of the Hashing Spec:
2026-07-01T00:00:00Z), and version 2 for all twts
created on or after the epoch.
A function that parses a twtxt file string, returning an object with information about the file and its owner (including hashes for each twt and any metadata in the file).
Pre-included examples:
/twtxt-demos/demo-hipster-twtxt.txt
/twtxt-demos/demo-pirate-twtxt.txt
/twtxt-demos/demo-sagan-twtxt.txt
Load
An async function that fetches a twtxt.txt-compatible file
from a URL and parses it, returning the extracted data as an object.
Pre-included examples:
/twtxt-demos/demo-hipster-twtxt.txt
/twtxt-demos/demo-pirate-twtxt.txt
/twtxt-demos/demo-sagan-twtxt.txt
Note that Cross-Origin Resource Sharing (CORS) restrictions may limit the effectiveness of using this function across domains.