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

txtfsm

v0.2.0

Published

TextFSM template parser

Readme

TxtFSM

An independent TypeScript implementation of TextFSM. TxtFSM turns semi-structured text, such as network device command output, into rows or JavaScript objects using TextFSM templates.

Documentation & Playground

[!NOTE] This project is under development and is not affiliated with Google or the original TextFSM project. It is based on the Apache 2.0-licensed original project and is released under the same license.

Features

  • Parse TextFSM templates and input entirely in JavaScript or TypeScript
  • Return records as arrays or objects keyed by the template header
  • Support multiple states and the Required, Filldown, Fillup, List, and Key value options
  • Support TextFSM rule actions including Record, NoRecord, Clear, Clearall, Next, Continue, and Error
  • Select templates from a TextFSM CLI table index and merge multi-template results by key
  • Ship ESM, CommonJS, and TypeScript declarations

Requirements

  • Node.js 22.12 or later

Installation

From npm:

npm install txtfsm

From JSR:

npx jsr add @txtfsm/txtfsm

Quick start

See the documentation & playground for a live demo.

API

TxtFSM

Create a reusable parser from a template:

const fsm = new TxtFSM(template);

const rows = fsm.parseText(input);
// TextFSMRow[]; each field is a string or, for Value List, string[]

const records = fsm.parseTextToDicts(input);
// TextFSMRecord[]; Value List properties remain string[]

For example, Value List VLAN produces { VLAN: ['10', '11'] } rather than a comma-delimited string.

Both parsing methods accept { eof: false } as a second argument to disable the implicit EOF record operation.

For one-off parsing, equivalent helper functions are available:

import { parseText, parseTextToDicts } from 'txtfsm';

const rows = parseText(template, input);
const records = parseTextToDicts(template, input);

parseTemplate

parseTemplate(source) validates and compiles a template, returning its value and state definitions. Invalid templates throw TxtFSMTemplateError; runtime parsing failures throw TxtFSMError.

CliTable

CliTable selects a template using an index compatible with TextFSM CLI tables. Provide the index text and a loader that returns template text by file name:

import { CliTable } from 'txtfsm';

const index = `Template, Platform, Command
show_items.textfsm, demo_os, sh[[ow]] it[[ems]]`;

const templates = new Map([
  [
    'show_items.textfsm',
    ['Value ID (\\d+)', 'Value STATE (\\w+)', '', 'Start', '  ^Item ${ID} ${STATE} -> Record'].join(
      '\n',
    ),
  ],
]);

const table = new CliTable(index, (name) => templates.get(name));
const records = table.parseCmd('Item 1 up', {
  Platform: 'demo_os',
  Command: 'show items',
});

// [{ ID: '1', STATE: 'up' }]

Abbreviated command patterns such as sh[[ow]] are supported. An index entry may also list multiple templates separated by :; their records are merged using values marked with the Key option. A missing matching row or template throws CliTableError.

Compatibility

TxtFSM aims to provide behavior compatible with Google TextFSM 2.1.0 for the supported syntax. Compatibility is checked against templates from ntc-templates. Because JavaScript and Python regular expression engines differ, templates that depend on Python-specific regex behavior may not be fully compatible. Please report reproducible differences through GitHub Issues.

Development

See CONTRIBUTING.md for the full contribution workflow.

License

Copyright 2026 yuyosy

The core library includes a TypeScript adaptation of portions of Google TextFSM:

  • https://github.com/google/textfsm

Applicable portions:

Copyright 2010, 2011, 2012, 2022 Google Inc. All Rights Reserved. Google TextFSM and this adaptation are licensed under the Apache License, Version 2.0.

For detailed attribution and a record of modifications, see the NOTICE file.