hwp2md — HWP to Markdown without Hancom Office
An open-source converter that extracts HWP documents to Markdown with their tables and headings intact, for servers and data pipelines that have no Hancom Office.

By the numbers
Every figure is a measured value with a source. Values from the rebuilt environment are marked as such.
Tests (public repo, CI)Reproducible measurement
793 unit, 103 E2E run
pytest -m "not real_samples" on a clean clone
Tests (full local suite, real samples included)Reproducible measurement
828 unit, 157 E2E collected
pytest --collect-only (real HWP samples included, Development log (private))
Runtime dependenciesReproducible measurement
2 (olefile, lxml)
pyproject.toml
Core codeReproducible measurement
5,621 lines of Python in 34 files
git ls-files 'src/*.py' | xargs cat | wc -l
CI jobsReproducible measurement
6 (lint, typecheck, unit 3.11·3.13, e2e, dist)
.github/workflows/ci.yml
Browser mode first loadReproducible measurement
About 65 s
Pyodide cold load, measured 1 time, 2026-10-23, Development log (private)
A workbench that opens sealed vault documents
How this project works, redrawn as one machine. Left alone it tours itself; press or drag to take over.
How it was solved
Problem
Most Korean public and corporate documents are HWP files. On a Linux server without Hancom Office their content is hard to get out, and text-only extractors lose tables and headings.
Decision
Runtime dependencies were cut to two: olefile and lxml. AES-128 decryption for distribution documents is ECB decryption written by hand, without adding cryptography.
Principle
A tool that opens a closed format should keep dependencies small and give the same result wherever it runs. The same code runs on the server and in the browser (Pyodide).
Structure
There are three layers. Three readers build the same list[Block], and one format-agnostic renderer writes Markdown. The CLI, library and web all call the same readers and renderer.
Result
The tool converts HWP 5.0, HWPX and HWPML to Markdown with tables and headings kept, released as CLI, library, web and executables. Public CI runs 793 unit tests and 103 E2E tests.
Real screens



1. Situation
Most Korean public-sector and corporate documents are in HWP format. On Linux servers or data pipelines where Hancom Office can't be installed, getting the content out of these files is hard. Text-only extractors exist, but they lose tables and heading structure, which makes them a poor fit for RAG chunking or for analyzing the budget and schedule tables in public notices.
The audience was RAG developers, data analysts pulling tables out of public notices, and anyone running a server where Hancom Office can't be installed. They all needed "text with the structure still in it," so I chose Markdown as the output format.
2. Scoping
A lot was cut from the start. DRM- and password-protected documents are not cracked; they are rejected with a dedicated exception. Headers and footers add noise to RAG chunks, so they are left out of the body and only their count is reported. GFM tables have no rowspan or colspan, so the first row becomes the header and merged cells are filled with blanks. The merge structure is lost, but row and column counts are preserved, which keeps the table easy to read for both people and RAG.
Dependencies were cut too. There are only two runtime dependencies, olefile and lxml. For AES-128 decryption of distribution (copy-restricted) documents, I implemented ECB decryption myself instead of pulling in cryptography. The point was to avoid adding native dependencies to the default install and the browser mode.
Test HWP files were synthesized in code rather than collected from public samples. Public samples are hard to clear for licensing, and synthesis gives byte-level control over variations such as compression and encryption flags. Edge cases from real documents are covered by local tests on real samples, which are excluded from CI.
3. Build
| Category | What | Rationale |
|---|---|---|
| Adopted | olefile (OLE compound files), lxml (XML), Pyodide (Python in the browser), PyInstaller (executables) | Compared with Nuitka and PyApp, PyInstaller builds with the same command on 4 OS runners, without a C compiler or Rust |
| Modified | Vendored 2 files of an equation converter under Apache-2.0 (NOTICE) | Keep only the parts needed instead of pulling in the whole external package |
| Built | HWP 5.0 record parser, AES-128 decryption, a block model and renderer shared by all three formats, web preview, release pipeline | Layout was matched by cross-checking the public spec against other open-source implementations |
The structure has three layers. An HWP 5.0 file is an OLE compound file holding zlib-compressed record streams. The reader follows the records' level tree to assemble paragraphs, tables, images, footnotes, equations, and links, and restores each object's position within a paragraph by matching extended control characters to the order in which CTRL_HEADER records appear. The 3 readers for HWP 5.0, HWPX, and HWPML all produce the same list[Block], and a single format-agnostic renderer turns that into Markdown. Supporting a new input format only takes a new reader.
The same code runs on the server and in the browser. Browser mode loads Pyodide and then runs the same convert_bytes using the hwp2md source bundled by the server. So the two modes never diverge, and file bytes never reach the server. Pushing a single vX.Y.Z tag ships to PyPI (hwp2markdown), executables for 4 OSes, and a GitHub Release; Homebrew installs it with brew install ilyos-numon/tap/hwp2md.
4. What broke
Two readers could produce different results for the same document. With three readers, the same content risks rendering differently per format. My hypothesis was that going through a single block model should make the output identical, so I added tests that use the synthetic generator to build the same input as both HWP 5.0 and HWPX and cross-check that the two readers emit the same blocks and the same Markdown. CLI, server, and browser outputs are also compared byte for byte in E2E.
Browser mode is slow the first time it opens. Bundling Pyodide into the wheel would add tens of MB, so it is fetched from a CDN instead. A single cold-load measurement showed the first load taking about 65 seconds.
Converted output from real samples could have been left in the pre-release history. Published as-is, anyone could have seen it. I backed up the repo, cleaned the history with git filter-repo, and made scripts/check_dist.py check on every build that no development logs, design files, or real samples end up in the sdist or wheel.
5. Results
I released a tool that converts HWP 5.0, HWPX, and HWPML to Markdown with tables and heading structure intact, without Hancom Office, as a CLI, a library, a web app, and standalone executables. There are no meaningful numbers yet for user count or conversion accuracy, so I don't report them.
| Metric | Value | Scope | Source |
|---|---|---|---|
| Tests (public CI) | 793 unit, 103 E2E run | Reimplementation | pytest -m "not real_samples" |
| Tests (full local suite) | 828 unit, 157 E2E collected | Reimplementation | pytest --collect-only |
| Runtime dependencies | 2 (olefile, lxml) | Reimplementation | pyproject.toml |
| Core code | 5,621 lines of Python in 34 files | Reimplementation | git ls-files line count |
| CI jobs | 6 | Reimplementation | .github/workflows/ci.yml |
| Browser mode first load | About 65 s (1 measurement) | Reimplementation | Development log (private), 2026-10-23 |
6. If I did it again
The remaining limits are clear. On Python 3.14, the error message for a corrupted zip differs, so 1 unit test fails (3.11 and 3.13, the CI targets, pass). Tests on real HWP samples are not in the repo because the sample licenses haven't been cleared, and the converter hasn't been verified against real HWP files containing charts. The executables are unsigned, so macOS and Windows show warnings, and the Homebrew tap is updated by hand.
If I did it again, I would secure a license-cleared set of real samples from day one and put it in CI. Synthetic documents are good for controlling variations, but they can't stand in for the edge cases of real documents.