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

typesxliff

v1.0.0

Published

TypeScript library for creating, loading, querying, and writing XLIFF 2.x documents

Readme

TypesXLIFF

TypesXLIFF is a TypeScript / Node.js library for parsing, generating, and validating XLIFF 2.x files (2.0, 2.1 and 2.2). It includes a fully typed object model and JSON conversion for processing translation and localization data.

Quick example

Load an XLIFF file and read the first source segment:


import { XliffParser } from "typesxliff";

const parser = new XliffParser();
parser.parseFile("file.xlf");

const doc = parser.getXliffDocument();
const segment = doc?.getFiles()?.[0]?.getEntries()?.[0];

if (segment && "getItems" in segment) {
    console.log(segment.getItems()[0]?.getSource()?.getContent().join(""));
}

Why TypesXLIFF

  • Full XLIFF 2.x object model (not just parsing)
  • Type-safe API for building and modifying documents
  • JSON round-trip for integration with other systems
  • Built on TypesXML (streaming XML parser with validation support)

Features

  • Parse XLIFF files — Load an existing XLIFF 2.x file into a fully typed object model using XliffParser
  • Build programmatically — Construct XliffDocument instances from scratch using the provided model classes
  • Write XLIFF files — Serialize any XliffDocument back to a well-formed XML file using XliffDocument.writeDocument()
  • JSON round-trip — Convert XLIFF ⇄ JSON (lossless) using XliffToJson, and reconstruct it back using JsonToXliff. Built on the round-trip JSON conversion provided by TypesXML
  • Validate — Each model element exposes an isValid() method that checks structural and semantic constraints against the XLIFF 2.x specification

Use cases

  • Parse XLIFF 2.x files in Node.js or TypeScript
  • Generate XLIFF documents programmatically
  • Convert XLIFF to/from JSON
  • Validate XLIFF structure and content
  • Build localization or translation pipelines

Documentation

Scope

TypesXLIFF provides type-safe classes for building, parsing, and serializing XLIFF documents. It covers:

  • XLIFF versions: 2.0, 2.1 and 2.2
  • Core structural elements: <xliff>, <file>, <skeleton>, <group>, <unit>, <segment>, <ignorable>, <notes>, <note>, <originalData>, <data>, <source> and <target>
  • Inline elements: <cp>, <ph>, <pc>, <sc>, <ec>, <mrk>, <sm> and <em>
  • Metadata module: <metadata>, <metaGroup> and <meta>
  • Translation Candidates module: <matches> and <match>
  • Glossary module: <glossary>, <glossEntry>, <term>, <translation> and <definition>

Each class includes validation (isValid()) and XML serialization (toElement()) methods.

Parsing an existing XLIFF file

import { Catalog } from "typesxml";
import { XliffParser, XliffDocument } from "typesxliff";

const parser = new XliffParser();
// Using a catalog is optional. When provided, the SAX parser can resolve grammar
// schemas and populate default attribute values declared in them.
// A sample catalog covering XLIFF 2.0, 2.1 and 2.2 is included in the catalog/ folder.
parser.setCatalog(new Catalog('/path/to/typesxliff/catalog/catalog.xml'));
parser.parseFile('/path/to/file.xlf');
const doc: XliffDocument | undefined = parser.getXliffDocument();

Building and writing an XLIFF document

import { XliffDocument, XliffFile, XliffUnit, XliffSegment, XliffSource } from "typesxliff";

const doc = new XliffDocument("2.1", "en", "es");

const file = new XliffFile("f1");
const unit = new XliffUnit("u1");
const segment = new XliffSegment("s1");
const source = new XliffSource();
source.addText("Hello, world!");
segment.setSource(source);
unit.addSegment(segment);
file.addUnit(unit);
doc.addFile(file);

doc.writeDocument('/path/to/output.xlf', true);

Dependencies

Installation

npm install typesxliff

Building from Source

npm install
npm run build