Parsing Korea's HWP government documents into Markdown for LLMs
Description and use
kordoc converts HWP/HWPX documents into Markdown and structured data, achieving 100% table structure accuracy and high PDF parsing precision, with support for air‑gapped environments.
Problem
Civil servants need to convert HWP/HWPX documents into Markdown for RAG pipelines and AI agents, but existing tools require Hancom Office or lack robust parsing.
Outcome
kordoc achieves 100% table structure match on 10,342 tables from 2,424 HWPX documents and 100% on 4,315 tables from 1,130 HWP5.x/HWPX pairs; PDF parsing scores 99.84% character recall and 99.16% reading order on 744 pairs; it supports air‑gapped operation with OCR on local CPU.
Workflow
- Install Node.js 20+ and npm package "kordoc".
- Run "npx kordoc document.hwpx -o document.md" to convert a single file.
- Use "npx kordoc *.pdf --jobs 4 -d ./output" to batch convert PDFs.
- Invoke the library in TypeScript with "import {parse} from 'kordoc'" and handle the result.
- Register the MCP server with "npx -y kordoc setup" to expose tools to agents.
- Use the Python SDK by installing the engine globally and the SDK locally, then call "client.parse(...)".
- Configure air‑gapped mode with environment variable "KORDOC_OFFLINE=1" and restrict file access with "KORDOC_ROOT".
- Use the companion tool "korean-law-mcp" for legal citation verification via the MCP registry.
Evidence
I built kordoc, an MIT‑licensed TypeScript library, CLI and MCP server that converts Korean documents into Markdown and structured data.
kordoc lays out tables in two passes: first it computes the grid size from colSpan/rowSpan, then it places cells.
On the 4.21.14 release verification (2026-10-10), all 10,342 visible tables from 2,424 original HWPX documents matched in structure (100%).
On 744 pairs: character recall 99.84%, precision 99.64%, reading order 99.16%, word-boundary F1 98.89%.
kordoc is meant to run on air-gapped networks too. KORDOC_OFFLINE=1 blocks all outbound traffic, and OCR runs on the local CPU with no API key.
- Record date: 2026-10-10T15:11:01.197Z