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

tally-xml-tdl

v1.16.1

Published

Simple, clean TDL and XML extraction and manipulation tools for Tally

Downloads

931

Readme

tally-xml-tdl

Simple, clean TDL and XML extraction and manipulation tools for Tally.

npm version License: MIT

Extract data directly from Tally Prime / Tally.ERP 9 using TDL XML requests over HTTP, and get back clean, developer-friendly JSON ready for modern web apps, APIs, dashboards, and databases.


📖 The Story

Interfacing with Tally usually means dealing with complex, deeply nested XML envelopes, verbose TDL message syntax, and responses filled with XML parser artifacts (@_RESERVEDNAME, #text, @_TYPE, etc.):

// Traditional Tally XML-to-JSON response (cluttered & nested):
{
  "ENVELOPE": {
    "BODY": {
      "DATA": {
        "COLLECTION": {
          "UNIT": [
            {
              "@_NAME": "Kgs",
              "@_RESERVEDNAME": "",
              "NAME": { "#text": "Kgs", "@_TYPE": "String" }
            }
          ]
        }
      }
    }
  }
}

tally-xml-tdl changes that. With version v6, it introduces a streamlined template-driven engine and two simple functions:

  • clean(): Strips all XML noise, flattens text nodes, removes reserved attributes, and returns plain JavaScript objects or arrays.
  • get(): Returns the full XML-to-JSON parsed object when you need raw envelope fidelity.
// With tally-xml-tdl clean():
[
  "Kgs"
]

🚀 Features

  • 🧹 Clean Data Out-of-the-Box: Automatically strips Tally metadata attributes and flattens nested values.
  • Two Extraction Modes: Choose clean() for clean data arrays, or get() for the full parsed envelope.
  • 📋 Pre-configured Queries: Built-in TDL queries for UOM, Stock Items, Stock Items with Base Units, and Ledgers.
  • 🏎️ Fast & Lightweight: Built on top of fast-xml-parser with minimal overhead.
  • 📦 Zero-Config HTTP Transport: Communicates directly with Tally's built-in HTTP server (http://localhost:9000).
  • 🔷 First-Class TypeScript Support: Full type declarations included (.d.ts).
  • 🌐 Modern ESM: Native ES modules with subpath exports (tally-xml-tdl and tally-xml-tdl/v6).

📦 Installation

npm install tally-xml-tdl

Prerequisites

Make sure Tally is running and its HTTP server is enabled:

  • Tally Prime / Tally.ERP 9: Press F12 (Configure) -> Advanced Configuration -> Set Tally is acting as to Both or Server, and note the port (default is 9000).

💡 Quick Start

import { clean, get } from "tally-xml-tdl";

// 1. Fetch clean, simplified data
const items = await clean({
    company: "My Company Name",
    jsonId: "stockItemsWithBaseUnits"
});

console.log(items);
// Output:
// [
//   { NAME: "Item A", BASEUNITS: "Nos" },
//   { NAME: "Item B", BASEUNITS: "Kgs" }
// ]

// 2. Fetch raw parsed JSON (full fidelity)
const raw = await get({
    company: "My Company Name",
    jsonId: "uom"
});

console.log(raw);

📚 API Reference

clean(options)

Sends the TDL query to Tally, parses the XML response, and cleans the resulting collection data.

clean<T = any>(options: V6Options): Promise<T>

Options:

| Option | Type | Required | Default | Description | | :--- | :--- | :---: | :--- | :--- | | company | string | Yes | — | Name of the active company in Tally. | | jsonId | string | Yes | — | ID of the pre-configured TDL query. | | url | string | No | "http://localhost:9000" | Tally HTTP endpoint URL. |


get(options)

Sends the TDL query to Tally and returns the complete XML response converted to a JavaScript object without stripping any metadata.

get<T = any>(options: V6Options): Promise<T>

🗂️ Built-in Query Catalog (jsonId)

| jsonId | Target Entity | Description | Fields Fetched | | :--- | :--- | :--- | :--- | | "uom" | Units of Measure | List of units of measurement | $$Alias:Name | | "stockItems" | Stock Items | List of inventory stock items | $$Alias:Name | | "stockItemsWithBaseUnits" | Stock Items | Inventory stock items with their base units | $$Alias:Name, BaseUnits | | "ledgerNames" | Ledgers | List of accounting ledgers | $$Alias:Name |


🎯 Advanced Usage

Connecting to a Remote or Custom Port

If Tally is hosted on another machine or running on a non-default port:

import { clean } from "tally-xml-tdl";

const data = await clean({
    company: "Acme Corp",
    jsonId: "ledgerNames",
    url: "http://192.168.1.100:9005"
});

Subpath Import

You can also explicitly import from the v6 subpath:

import { clean, get } from "tally-xml-tdl/v6";

Using Namespaces

import { v6 } from "tally-xml-tdl";

const data = await v6.clean({ company: "Acme Corp", jsonId: "uom" });

📄 License

MIT © KeshavSoft