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

obj-exporter

v0.2.0

Published

Export face-vertex and polygon meshes to the OBJ format

Readme

obj-exporter

Export array-based representations of 3D models to Wavefront OBJ files.

Works as a Node stream (one face per chunk) for memory-efficient conversion of large meshes, or as a synchronous function for in-memory data.

Installation

npm install obj-exporter

Requires Node.js 18 or newer.

Mesh format

A mesh is a list of polygonal faces. Each face has an array of vertices with x, y, z coordinates. Vertices that appear in more than one face are deduplicated automatically.

interface Vertex { x: number; y: number; z: number }
interface Face   { vertices: Vertex[]; normal?: Vertex }
interface Mesh   { faces: Face[] }

Example:

const tetrahedron = {
  faces: [
    {
      vertices: [
        { x: 1, y: 0, z: 0 },
        { x: 0, y: 1, z: 0 },
        { x: 0, y: 0, z: 1 },
      ],
    },
    {
      vertices: [
        { x: 0, y: 0, z: 0 },
        { x: 1, y: 0, z: 0 },
        { x: 0, y: 0, z: 1 },
      ],
    },
  ],
}

Library usage

Synchronous conversion

import { writeFileSync } from "node:fs"
import { toObj } from "obj-exporter"

writeFileSync("tetrahedron.obj", toObj(tetrahedron))

Produces:

o Solid Object

v 1 0 0
v 0 1 0
v 0 0 1
v 0 0 0

f 1 2 3
f 4 1 3

Streaming conversion

Json2obj is a node:stream Transform. By default it consumes face objects (writableObjectMode: true) and emits OBJ text.

import { createWriteStream } from "node:fs"
import { Readable } from "node:stream"
import Json2obj from "obj-exporter"

Readable.from(tetrahedron.faces)
  .pipe(new Json2obj())
  .pipe(createWriteStream("tetrahedron.obj"))

To consume a newline-delimited JSON stream of faces instead of objects, disable writable object mode:

process.stdin
  .pipe(new Json2obj({ writableObjectMode: false }))
  .pipe(process.stdout)

Lower-level builder

If you want to assemble an OBJ string without involving streams, use ObjBuilder directly:

import { ObjBuilder } from "obj-exporter"

const builder = new ObjBuilder()
for (const face of tetrahedron.faces) builder.addFace(face)
const obj = builder.toString()

CLI usage

The package installs an obj-exporter binary that converts a YAML or JSON mesh file to OBJ on stdout.

# From a file (mesh loaded into memory)
obj-exporter tetrahedron.yaml > tetrahedron.obj

# From a stream of newline-delimited JSON faces
cat faces.ndjson | obj-exporter > out.obj

API

| Export | Type | Description | | ------------------ | ------------------------------------------------- | ----------------------------------------------------------------- | | toObj(mesh) | (mesh: Mesh) => string | Convert a { faces } object to an OBJ string. | | Json2obj | class extends stream.Transform | Streaming converter. Default: object input, text output. | | ObjBuilder | class { addFace(face); toString(): string } | Incrementally builds an OBJ string, deduplicating vertices. | | Vertex, Face, Mesh | TypeScript types | Re-exported for typed usage. |

Development

npm install
npm test       # runs the TypeScript test suite via tsx
npm run build  # emits ESM + .d.ts files to dist/