jww-parser
v2025.12.4
Published
JWW (Jw_cad) file parser and DXF converter for JavaScript/TypeScript
Maintainers
Readme
jww-parser
JWW (Jw_cad) file parser and DXF converter for JavaScript/TypeScript.
This package uses WebAssembly to parse JWW binary files (created by Jw_cad, a popular Japanese CAD software) and convert them to DXF format.
Installation
npm install jww-parserUsage
Node.js
import { createParser } from 'jww-parser';
import { readFileSync } from 'fs';
async function main() {
// Create and initialize the parser
const parser = await createParser();
// Read a JWW file
const jwwData = readFileSync('drawing.jww');
const data = new Uint8Array(jwwData);
// Parse JWW to get document structure
const doc = parser.parse(data);
console.log('Entities:', doc.Entities.length);
console.log('Layers:', doc.LayerGroups.length);
// Convert to DXF string
const dxfString = parser.toDxfString(data);
writeFileSync('output.dxf', dxfString);
}
main();Browser
<!-- Include wasm_exec.js from Go -->
<script src="wasm_exec.js"></script>
<script type="module">
import { createParser } from 'jww-parser';
async function convertFile(file) {
const parser = await createParser('path/to/jww-parser.wasm');
const buffer = await file.arrayBuffer();
const data = new Uint8Array(buffer);
// Get DXF content
const dxfString = parser.toDxfString(data);
// Download as file
const blob = new Blob([dxfString], { type: 'application/dxf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = file.name.replace('.jww', '.dxf');
a.click();
}
</script>API
createParser(wasmPath?: string): Promise<JwwParser>
Create and initialize a JWW parser instance.
wasmPath- Optional path to thejww-parser.wasmfile
JwwParser
init(): Promise<void>
Initialize the WASM module. Called automatically by createParser().
parse(data: Uint8Array): JwwDocument
Parse a JWW file and return the document structure.
toDxf(data: Uint8Array): DxfDocument
Parse a JWW file and convert to DXF document structure (JSON).
toDxfString(data: Uint8Array): string
Parse a JWW file and convert to DXF file content string.
Types
JwwDocument
interface JwwDocument {
Version: number;
Memo: string;
PaperSize: number;
LayerGroups: LayerGroup[];
Entities: JwwEntity[];
Blocks: JwwBlock[];
}JwwEntity
Supported entity types:
JwwLine- Line segmentsJwwArc- Arcs and circlesJwwPoint- PointsJwwText- Text annotationsJwwSolid- Solid fillsJwwBlockRef- Block references
DxfDocument
interface DxfDocument {
Layers: DxfLayer[];
Entities: DxfEntity[];
Blocks: DxfBlock[];
}Requirements
- Node.js >= 18.0.0 (for Node.js usage)
- Modern browser with WebAssembly support (for browser usage)
License
AGPL-3.0
