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

hwpx-ts

v0.1.0

Published

TypeScript library for reading and writing HWPX files

Readme

hwpx-ts

TypeScript/JavaScript library for reading and writing HWPX (한글) files.

Installation

npm install hwpx-ts
# or
yarn add hwpx-ts
# or
pnpm add hwpx-ts

Usage

Reading HWPX Files

import { HwpxReader, readHwpxFile } from 'hwpx-ts';

// Node.js - from file
const reader = await readHwpxFile('./document.hwpx');

// Browser - from ArrayBuffer
const response = await fetch('/document.hwpx');
const data = await response.arrayBuffer();
const reader = new HwpxReader(data);
await reader.parse();

// Get text content
const text = reader.getText();
console.log(text);

// Get document info
const info = reader.getInfo();
console.log(info.paragraphCount, info.tableCount, info.imageCount);

// Get paragraphs
const paragraphs = reader.getParagraphs();

// Search
const results = reader.search('검색어');

// Convert to Markdown
const markdown = reader.toMarkdown();

// Convert to JSON
const json = reader.toJson();

Creating HWPX Files

import { HwpxExporter } from 'hwpx-ts';

const exporter = new HwpxExporter();

// Add heading
exporter.addHeading('문서 제목', 1);

// Add paragraph
exporter.addParagraph('본문 텍스트입니다.', {
  bold: true,
  alignment: 'center',
});

// Add table
exporter.addTable([
  ['이름', '나이', '직업'],
  ['홍길동', '30', '개발자'],
  ['김철수', '25', '디자이너'],
]);

// Add page break
exporter.addPageBreak();

// From Markdown
exporter.fromMarkdown(`
# 제목

본문 내용

## 소제목

- 목록 1
- 목록 2
`);

// Build and save (Node.js)
await exporter.saveToFile('./output.hwpx');

// Build as Uint8Array (Browser)
const data = await exporter.build();
const blob = new Blob([data], { type: 'application/octet-stream' });

Unit Conversions

import { mmToHwpunit, hwpunitToMm, ptToHwpunit, hwpunitToPt } from 'hwpx-ts';

// Convert 10mm to HWPUNIT
const hwpunit = mmToHwpunit(10);  // 567

// Convert HWPUNIT to mm
const mm = hwpunitToMm(567);  // 10

// Convert 12pt to HWPUNIT
const hwpunit2 = ptToHwpunit(12);  // 240

API Reference

HwpxReader

| Method | Description | |--------|-------------| | parse() | Parse the HWPX file | | getText() | Get full text content | | getParagraphs() | Get all paragraphs | | getParagraph(index) | Get paragraph by index | | getParagraphText(index) | Get paragraph text by index | | getTables() | Get all tables | | getImages() | Get all images | | getImageData(id) | Get image binary data | | getInfo() | Get document info | | search(query, caseSensitive?) | Search text | | toJson() | Convert to JSON | | toMarkdown() | Convert to Markdown |

HwpxExporter

| Method | Description | |--------|-------------| | addParagraph(text, options?) | Add a paragraph | | addHeading(text, level?, alignment?) | Add a heading | | addTable(data, options?) | Add a table | | addImage(data, filename?, options?) | Add an image | | addPageBreak() | Add a page break | | addLineBreak() | Add an empty line | | fromMarkdown(markdown) | Create from Markdown | | build() | Build as Uint8Array | | saveToFile(path) | Save to file (Node.js) |

Types

interface DocumentInfo {
  paragraphCount: number;
  tableCount: number;
  imageCount: number;
  sectionCount: number;
  binaryItems: number;
}

interface Paragraph {
  inlines: InlineElement[];
  alignment?: AlignmentType;
  // ...
}

interface Table {
  rowCount: number;
  colCount: number;
  cells: TableCell[];
  // ...
}

type AlignmentType = 'left' | 'right' | 'center' | 'justify' | 'distribute';

License

AGPL-3.0