
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
DXF parser with rich type definitions.
[!CAUTION] This is parser is not in stable state yet. Until version 1.0, we may often change name or type of the variables. We're adding rich unit/integration test, but there might be unexpected bug or uncovered situation. Note that official DXF specification is poorly documented, so that many informations are missing and even errors exist. Use your own risk. Thank you for your consideration.
npm i dxf-json # or your loved package manager
import { readFileSync } from 'fs'
import { DxfParser } from 'dxf-json'
const content = readFileSync('foo.dxf', 'utf-8')
const parser = new DxfParser()
const parsedDxf = parser.parseSync(content)
// play with your dxf file
const lwPolylines = parsedDxf.entities.filter(
(entity) => entity.type === 'LWPOLYLINE',
)
moduleResolution in TypeScriptIt's impossible to support both ESM and CJS with node16, because they detect type of modules only by type field in package.json or the extension of files. To support CJS with node16, we have to rename every .d.ts files into .d.cts, not only the file name but also every import expression in source files.
But Node16 is already deprecated, and to maintain the open source society healthy, we decided not to support require at that version. Also we highly recommend to use ESM styled import consistently throughout your source code.
| Module Resolution | From ESM | From CJS |
|---|---|---|
node10 | ✅ | ✅ |
node16 | ✅ | ❌ |
bundler | ✅ | ✅ |
[!NOTE] We support standard specification of dxf and AutoCAD features only. We're trying our best to support universal dxf files, but we don't support 3rd party specification.
For dev branch status, see #52
Based on AutoCAD 2024 DXF Reference
[!NOTE] The documentation is not ready, but you can check the source code for used types #1 and #2
You can configure how the THUMBNAILIMAGE section is parsed by setting the thumbnailImageFormat option:
import { DxfParser } from 'dxf-json'
// Default: base64 format (ready for web display)
const parser1 = new DxfParser()
const result1 = parser1.parseSync(dxfContent)
// result1.thumbnailImage.data is a base64 string
// Usage: <img src="data:image/bmp;base64,${result1.thumbnailImage.data}" />
// Hex format (raw hexadecimal string)
const parser2 = new DxfParser({ thumbnailImageFormat: 'hex' })
const result2 = parser2.parseSync(dxfContent)
// result2.thumbnailImage.data is a hex string
// Buffer format (Node.js Buffer object)
const parser3 = new DxfParser({ thumbnailImageFormat: 'buffer' })
const result3 = parser3.parseSync(dxfContent)
// result3.thumbnailImage.data is a Buffer
// Save to file: fs.writeFileSync('thumbnail.bmp', result3.thumbnailImage.data)
Available formats:
'base64' (default): Base64-encoded string, ideal for web applications'hex': Raw hexadecimal string from the DXF file'buffer': Node.js Buffer object for file operations[!NOTE] The thumbnail image in DXF files is typically in BMP format.
parseSyncconst parser = new DxfParser()
return parser.parseSync(buffer)
parseStreamimport fs from 'fs'
const parser = new DxfParser()
const fileStream = fs.createReadStream('dxf file path', { encoding: 'utf8' })
return await parser.parseStream(fileStream)
parseUrlconst parser = new DxfParser()
return await parser.parseFromUrl(url, encoding, RequestInit)
See CONTRIBUTING.md
FAQs
perfect dxf parser
The npm package dxf-json receives a total of 563 weekly downloads. As such, dxf-json popularity was classified as not popular.
We found that dxf-json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.