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

@csvw-rdf-convertor/core

v1.0.1

Published

The core library for bidirectional conversion between CSV-W (CSV on the Web) and RDF formats, with full W3C CSVW specification support and validation capabilities.

Readme

@csvw-rdf-convertor/core

The core library for bidirectional conversion between CSV-W (CSV on the Web) and RDF formats, with full W3C CSVW specification support and validation capabilities.

Features

  • 🔄 Bidirectional conversion between CSVW and RDF formats
  • 📊 Multiple RDF serializations (Turtle, N-Triples, N-Quads, TriG, JSON-LD and RDF/XML)
  • CSVW validation against W3C specification
  • 🚀 Streaming support for large datasets
  • 🎯 Schema inference from RDF data
  • 📝 Template IRIs and custom prefix support
  • 🔧 Configurable options for fine-tuned conversion
  • 📋 Issue tracking with detailed error reporting

Installation

npm install @csvw-rdf-convertor/core

Quick Start

CSVW to RDF Conversion

import { csvwDescriptorToRdf, Csvw2RdfOptions } from '@csvw-rdf-convertor/core';
import fs from 'node:fs';

const descriptor = JSON.parse(fs.readFileSync('metadata.json', 'utf8'));
const options: Csvw2RdfOptions = {
  templateIris: true,
  minimal: false,
  resolveJsonldFn: yourJsonLdLoaderFunction,
};

// create a RDF.js Stream of quads
const rdfStream = csvwDescriptorToRdf(descriptor, options);

RDF to CSVW Conversion

import {
  rdfToCsvw,
  parseRdf,
  rdfToTableSchema,
} from '@csvw-rdf-convertor/core';

// Parse RDF data
const getRdfStream = () => parseRdf('https://example.org/data.ttl');
// In order to support the browser environment, the library can by default
// only fetch from URLs. To load local files, you can use a custom resolveStreamFn option.
// parseRdf('https://example.org/data.ttl', { resolveStreamFn: customResolveStreamFn });

// In the first pass, we infer the schema:
const schema = await rdfToTableSchema(await getRdfStream());

// Then, we convert the RDF data in the second pass:
const csvwStream = rdfToCsvw(await getRdfStream(), { descriptor: schema });

// Process the CSVW output
for await (const { descriptor, table, row } of csvwStream) {
  console.log({ descriptor, table, row });
}

CSVW Validation

import {
  validateCsvwFromDescriptor,
  Csvw2RdfOptions,
} from '@csvw-rdf-convertor/core';

const descriptor = '{"@context": "http://www.w3.org/ns/csvw", ...}';
const options: Csvw2RdfOptions = { baseIri: 'http://example.org/' };

// Validate and collect issues
for await (const issue of validateCsvwFromDescriptor(descriptor, options)) {
  console.log(`${issue.type}: ${issue.message}`);
  if (issue.location) {
    console.log(`  at ${issue.location.row}:${issue.location.column}`);
  }
}

Configuration Options

Csvw2RdfOptions

Options for CSVW to RDF conversion:

interface Csvw2RdfOptions extends ConversionOptions {
  /** Use template IRIs instead of full URIs (default: false) */
  templateIris?: boolean;

  /** Generate minimal RDF output, omitting optional metadata (default: false) */
  minimal?: boolean;

  /** Function for loading CSV files */
  resolveCsvStreamFn?: ResolveCsvStreamFn;

  /** Function for loading .well-known/csvm files */
  resolveWkfFn?: ResolveWkfFn;
}

Rdf2CsvOptions

Options for RDF to CSVW conversion:

interface Rdf2CsvOptions extends ConversionOptions {
  /** CSVW descriptor template for conversion */
  descriptor?: string | AnyCsvwDescriptor | TableGroupSchema;

  /** Use vocabulary metadata to enrich conversion (default: false) */
  useVocabMetadata?: boolean;

  /** Number of quads to process at once (default: auto) */
  windowSize?: number;

  /** Function for loading remote RDF data */
  resolveRdfFn?: ResolveRdfFn;
}

ConversionOptions

Base options for all conversions:

interface ConversionOptions {
  /** Path replacement patterns [pattern, replacement] */
  pathOverrides?: [string | RegExp, string][];

  /** Base IRI for resolving relative references */
  baseIri?: string;

  /** Function for loading JSON-LD resources */
  resolveJsonldFn?: ResolveJsonldFn;

  /** Logging level (Error=0, Warn=1, Debug=2) */
  logLevel?: LogLevel;

  /** Caching interface for remote resources */
  cache?: FetchCacheInterface;
}

Supported RDF Formats

| Format | MIME Type | Extension | Streaming | | --------- | ----------------------- | ------------ | --------- | | Turtle | text/turtle | .ttl | ✅ | | N-Triples | application/n-triples | .nt | ✅ | | N-Quads | application/n-quads | .nq | ✅ | | TriG | application/trig | .trig | ✅ | | JSON-LD | application/ld+json | .jsonld | ✅ | | RDF/XML | application/rdf+xml | rdf, xml | ✅ |

Performance Considerations

  • Streaming: Use streaming APIs for large datasets to minimize memory usage
  • Window Size: Adjust windowSize for RDF to CSVW conversion based on available memory
  • Minimal Mode: Use minimal: true for faster conversion when metadata richness isn't required

TypeScript Support

The library is written in TypeScript and provides comprehensive type definitions:

Documentation

Developer documentation available here: Dev doc Full API documentation is available online: https://s0ft1.github.io/CSVW-RDF-convertor/