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

@linkiez/dxf-renew

v7.2.4

Published

DXF parser for node/browser

Downloads

594

Readme

DXF-Renewed

Build Status semantic-release: conventionalcommits

⚠️ WARNING: This repository is currently under development and has not been fully tested in production. Use at your own risk.

DXF parser for node/browser.

Written in TypeScript with full type definitions included. Uses modern ES2015+ features and is built with esbuild for optimal performance.

Note: This is a renewed and modernized fork of the original dxf library, with complete TypeScript migration, enhanced performance, and additional features.

TL;DR

  • Parse: parseString(dxfText) → typed ParsedDXF
  • Expand blocks: denormalise(parsed) → flat Entity[] with transforms
  • Render/export:
    • toSVG(parsed) → SVG string
    • toPolylines(parsed) → numeric polyline arrays
    • toJson(parsed) → JSON string

Features

  • TypeScript-first public API (strict typing)
  • Deterministic parsing + regression coverage via real DXF fixtures
  • INSERT/BLOCK expansion (denormalisation) with transform stacking
  • SVG rendering for common 2D geometry + annotation entities
  • Polyline output for custom renderers (Canvas/WebGL/etc.)
  • Framework-agnostic (no React/Webpack required)

Documentation

Table of Contents

Version History

Version 2.0 - Complete rewrite from SAX-style parsing to handle nested references properly (inserts, blocks, etc.)

Version 3.0 - Adopted standard JS, ES6 imports, removed Gulp, updated dependencies

Version 4.x - Native SVG elements where possible (<circle />, <ellipse />, etc.)

Version 5.x (Current) - Complete TypeScript migration:

  • 🎯 Full TypeScript codebase with strict type checking
  • ⚡ Built with esbuild (96% faster than Babel - 18ms vs 447ms)
  • 📦 Modular type system with 22+ separate type files
  • ✅ Extensive unit tests and browser integration tests
  • 🎨 Enhanced SVG rendering with TEXT, MTEXT, and DIMENSION support
  • 📚 Comprehensive type definitions for all DXF entities

Supported Entities

Many common DXF entities are parsed and rendered to SVG. Some entities are parsed but currently skipped during SVG rendering.

Rendered to SVG

  • LINE - Straight line segments
  • CIRCLE - Native SVG <circle /> element
  • ARC - Circular arcs with native SVG paths
  • ELLIPSE - Native SVG <ellipse /> element
  • LWPOLYLINE - Lightweight polylines with bulges
  • POLYLINE - 2D/3D polylines with vertices
  • SPLINE - B-spline curves (degree 2-3 as Bézier, others interpolated)
  • TEXT - Single-line text with rotation
  • MTEXT - Multi-line text with formatting
  • DIMENSION - Linear, aligned, radial, diameter, and ordinate dimensions
  • SOLID - Solid-filled triangles and quadrilaterals
  • TRACE - Rendered as a filled path outline
  • RAY/XLINE - Rendered as polylines
  • WIPEOUT - Rendered as outline fallback
  • LEADER - Rendered as an SVG path (basic)
  • TOLERANCE - Rendered with SVG text fallback
  • SHAPE - Rendered with SVG text fallback

INSERT note: INSERT is supported via denormalisation. The library expands INSERT entities into their referenced BLOCK contents and then renders the resulting entities with transforms applied.

Parsed (Not Rendered)

  • ⚠️ POINT - Parsed but currently not rendered to SVG
  • ⚠️ 3DFACE - Parsed but currently not rendered to SVG
  • ⚠️ HATCH - Parsed but currently not rendered to SVG
  • ⚠️ ATTDEF/ATTRIB - Block attributes parsed
  • ⚠️ Text styles (STYLE table) - Parsed (colors supported; fonts are not applied to SVG)

Getting started

TypeScript example with full type safety:

import { Helper } from '@linkiez/dxf-renew'

const helper = new Helper(dxfString)

// The 1-to-1 object representation of the DXF
console.log('parsed:', helper.parsed)

// Denormalised blocks inserted with transforms applied
console.log('denormalised:', helper.denormalised)

// Create an SVG
console.log('svg:', helper.toSVG())

// Create polylines (e.g. to render in WebGL)
console.log('polylines:', helper.toPolylines())

// Create a JSON representation (1-to-1 with the parsed model)
console.log('json:', helper.toJson({ pretty: true }))

JavaScript example:

const { Helper } = require('@linkiez/dxf-renew')

const helper = new Helper(dxfString)

// The 1-to-1 object representation of the DXF
console.log('parsed:', helper.parsed)

// Denormalised blocks inserted with transforms applied
console.log('denormalised:', helper.denormalised)

// Create an SVG
console.log('svg:', helper.toSVG())

// Create polylines (e.g. to render in WebGL)
console.log('polylines:', helper.toPolylines())

// Create a JSON representation (1-to-1 with the parsed model)
console.log('json:', helper.toJson({ pretty: true }))

API

The public API is exported from src/index.ts.

  • parseString(dxfText: string): ParsedDXF
    • Parse DXF text into a typed model.
  • denormalise(parsed: ParsedDXF): Entity[]
    • Expand INSERT entities into their referenced BLOCK contents.
  • toSVG(parsed: ParsedDXF, options?): string
    • Render the drawing to an SVG string.
  • toPolylines(parsed: ParsedDXF, options?): any[]
    • Convert supported entities to polyline arrays.
  • toJson(parsed: ParsedDXF, options?): string
    • Serialize the parsed model as JSON.
  • Helper
    • Convenience wrapper that exposes parsed, denormalised, plus toSVG(), toPolylines(), and toJson().

Running the Examples

There are examples in the examples/ directory.

Node ES6 (TypeScript). Will write an SVG to examples/example.es6.svg:

npx tsx examples/example.es6.js

Node ES5. Will write an SVG to examples/example.es5.svg:

node examples/example.es5.js

Browser. Compile to a browser bundle and open the example webpage:

yarn compile
open examples/dxf.html

Package Manager

This project uses Yarn 4 (Berry) as the package manager. Make sure you have Yarn installed:

# Install via npm
npm install -g yarn

# Or via corepack (recommended)
corepack enable

All npm commands in the documentation can be replaced with yarn equivalents:

  • npm installyarn install or just yarn
  • npm testyarn test
  • npm run compileyarn compile

SVG

Geometric elements are fully supported with native SVG elements where possible (<circle />, <ellipse/>, etc.). TEXT, MTEXT, and DIMENSION entities are now fully rendered with proper transformations and formatting.

SPLINE entities with degree 2-3 and no weights are converted to native Bézier curves. Other splines are interpolated as polylines.

Here's an example you will find in the functional test output:

svg example image

DIMENSION auto-scaling

DIMENSION rendering supports viewport-based auto-scaling so that arrows and text remain readable across different coordinate scales.

import { Helper } from '@linkiez/dxf-renew'

const helper = new Helper(dxfString)

const svg = helper.toSVG({
  dimension: {
    autoScale: true,
    // Reference used when percentages are not provided.
    autoScaleViewportReference: 40,
    // Optional per-element overrides as a percentage (0..100)
    // of min(viewBoxWidth, viewBoxHeight).
    autoScaleViewportPercentages: {
      arrowSize: 1.5,
      textHeight: 1
    }
  }
})

When autoScaleViewportPercentages is provided (and autoScale is enabled), the final size for each configured element is computed as:

size = min(viewBoxWidth, viewBoxHeight) * (percent / 100)

Interpolation

The library supports outputting DXFs as interpolated polylines for custom rendering (e.g. WebGL) or other applications:

const polylines = helper.toPolylines()

Command line

There is a command-line utility (courtesy of @Joge97) for converting DXF files to SVG:

yarn global add @linkiez/dxf-renew
# or
npm i -g @linkiez/dxf-renew

dxf-to-svg --help

Usage:

Usage: dxf-to-svg [options] <dxfFile> [svgFile]

Converts a dxf file to a svg file.

Options:
  -V, --version  output the version number
  -v --verbose   Verbose output
  -h, --help     output usage information

Tests

Running the unit tests:

yarn test

Running the browser integration tests (Playwright):

yarn test:integration:browser

These tests render fixtures in a real browser and write deterministic PNG screenshots under test/rendered/ (overwritten on each run).

Running the functional tests in a browser:

yarn test:functional

This starts a Vite dev server and opens http://localhost:8030/toSVG.html.

Development Guidelines

Project documentation index: ROADMAP.md (see “Documentation (Consolidated)”).

TypeScript Support

This library is written in TypeScript and includes full type definitions. All DXF entities, configuration options, and helper methods are fully typed.

Example with type imports:

import { Helper, ParsedDXF, Entity, LineEntity, CircleEntity } from '@linkiez/dxf-renew'

const helper = new Helper(dxfString)
const parsed: ParsedDXF = helper.parsed
const entities: Entity[] = helper.denormalised

// Type narrowing
entities.forEach((entity) => {
  if (entity.type === 'LINE') {
    const line = entity as LineEntity
    console.log(`Line from (${line.start.x}, ${line.start.y}) to (${line.end.x}, ${line.end.y})`)
  }
})

Build System

The project uses esbuild for compilation, which is significantly faster than Babel:

  • Build time: ~18-22ms (vs 447ms with Babel)
  • 96% performance improvement
  • Full TypeScript support with type checking via tsc
  • Yarn 4 (Berry) as package manager

Build commands:

yarn compile        # Compile TypeScript to JavaScript
yarn type-check     # Run TypeScript type checking
yarn test           # Run all tests

Credits

This project is a modernized fork of the original dxf library by skymakerolof, which itself was based on the work by bjnortier and many contributors. DXF-Renewed aims to maintain and improve upon this excellent foundation with modern TypeScript, enhanced performance, and new features.

Releases

This project uses semantic-release for automated version management and package publishing.

Releases are automatically created when commits following Conventional Commits are pushed to:

  • main - Stable production releases (1.0.0, 1.1.0, 2.0.0)

Commit Format

# New feature → MINOR version (1.0.0 → 1.1.0)
feat(dimension): add DIMSTYLE color support

# Bug fix → PATCH version (1.0.0 → 1.0.1)
fix(parser): correct POLYLINE parsing

# Breaking change → MAJOR version (1.0.0 → 2.0.0)
feat!: migrate to pure ESM

BREAKING CHANGE: CommonJS is no longer supported

Contributing

To contribute:

  1. Fork the repository
  2. Make commits using yarn commit (interactive) or following Conventional Commits
  3. Push to your fork
  4. Open a Pull Request to main

See CONTRIBUTING.md for detailed guidelines.

Contributors

Original dxf Library Contributors

DXF-Renewed Maintainers

License

See LICENSE file for details.