• Overview

    twtxt-lib

    An isomorphic TypeScript library of utility functions for parsing and interacting with twtxt.txt files.

    These functions include:

    • hashTwt: takes the constituent parts of a “twt” and generates an extension-compatible hash for it.
    • parseTwtxt: 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).
    • loadAndParseTwtxtFile: fetches a twtxt file from the internet and parses it into an object (as above).

    Features

    • Isomorphic, available as an (optionally minified) ES6+ library for the browser, with NPM and JSR versions coming soon.
    • Fully typed and source-mapped.
    • ESM (and ESM only)
    • Includes an interactive demo (you're looking at it).

    Installation

    Browser

    • Download library (or minified version).
    • Import desired function(s) into your project: `import { hashTwt, loadAndParseTwtxtFile } from "./twtxt-lib.js"`

    JSR

    • Coming soon

    NPM

    • Coming soon

    Use the tabs to learn more.


    Example parsed file from /twtxt-demos/demo-hipster-twtxt.txt :

    Copyright © 2026 Eric Woodward, released under the MIT License.

  • hashTwt

    A function that takes the constituent parts of a “twt” and generates an extension-compatible hash for it.

  • parseTwtxt

    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

    Note that CORS restrictions may limit the effectiveness of using this function from another domain.

  • loadAndParseTwtxtFile

    An async function that fetches a twtxt.txt-compatible file from a URL and parses it into 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 CORS restrictions may limit the effectiveness of using this function from another domain.