Skip to content
kordoc logo

kordoc

By chrisryugj·3,190

Parse Korean documents (HWP, HWPX, PDF, XLSX, DOCX, PPTX) to Markdown; fill forms, diff, render.

kordoc

모두 파싱해버리겠다. Parse them all.

npm version
npm downloads
GitHub stars
license
MCP Registry

Korea's document hell is second to none. Built by a civil servant who survived seven years in it.

kordoc lets AI read and write Korean government documents. It converts HWP 3.x/5.x, HWPX, HWPML, PDF, XLS/XLSX, DOCX, PPTX and images (PNG/JPG/WebP/TIFF/GIF/BMP/AVIF/HEIC/PCX) to Markdown and structured data, and writes HWPX or HWP government documents from Markdown. Use it as a library, CLI, HTTP API, or MCP server.

한국어 · Türkçe · Usage guide · Benchmarks · Changelog

kordoc output for the same statute annex given as HWP, HWPX, PDF and a scanned image

Actual output for one statute annex given as HWP, HWPX, PDF and a scanned image. All four read the merged cells (rowspan, colspan) into the same table structure. OCR turns on automatically for images.

  • 📊 0.965 overall on the public PDF benchmark: opendataloader-bench, 200 documents, higher than the 12 parsers on the public leaderboard (as recorded on 2026-09-29; measured on 4.24.50). Measurement details
  • 🇰🇷 100% Korean document table structure match: all 10,344 visible tables from 2,424 original HWPX documents. Validation
  • 🧩 Published in the Claude plugin directory: 1,700+ installs (as of 2026-11-14). Also listed on the official MCP Registry.

If this saves you time, a GitHub ⭐ helps others find it.

Videos (Korean): public benchmark run (2026-09-27 cut, 1 min 31 sec) · batch form filling demo

Contents: Install · Quick start · Features · Validation · Recent updates · FAQ · Documentation and security

Install

Node.js 20+ · macOS / Linux / Windows

npm install kordoc

Run the CLI without installing it globally: npx kordoc. PDF text is read by a WebAssembly engine shipped in the package. OCR, image-format conversion and QR-reading dependencies are installed by default; omitting them with --omit=optional limits those features.

Connect an AI agent

Where How
Claude Desktop, Claude Code, Cursor, Codex and others npx -y kordoc setup finds installed clients and registers the MCP server
VS Code, Cursor Use the buttons below
Claude Code plugin /plugin marketplace add chrisryugj/kordoc, then /plugin install kordoc@kordoc
Claude apps Find kordoc in the plugin directory and install it
Other MCP clients Official MCP Registry io.github.chrisryugj/kordoc or manual setup

Install in VS Code Install in Cursor

Restart the client to use 22 tools for parsing, comparison, generation, review, rendering and more. If registration fails, see manual MCP setup and installation troubleshooting.

Quick start

CLI

npx kordoc document.hwpx -o document.md
npx kordoc *.pdf --jobs 4 -d ./output
npx kordoc document.pdf --format json --pages 1-3
npx kordoc scan.pdf --ocr -o scan.md
npx kordoc generate report.md --preset report -o report.hwpx
npx kordoc to-hwpx document.hwp -o document.hwpx
npx kordoc to-hwpx ./old-docs   # whole folder (subfolders too): .hwpx next to each file, existing ones skipped
npx kordoc document.pdf -o document.hwpx   # PDF, DOCX and others become HWPX from what was read (images included)
npx kordoc pack build report1.hwpx report2.hwpx report3.hwpx --name Gwangyang -o gwangyang.kpack   # agency pack (docs/agency-pack-en.md)
npx kordoc generate new-report.md --pack gwangyang.kpack -o new-report.hwpx
npx kordoc fill --template gian -j values.json -o draft.hwpx
npx kordoc lint report.hwpx --gate --preset report

--jobs converts files in parallel and increases memory use. Batch conversion details

JavaScript / TypeScript

import { parse, markdownToHwpx } from "kordoc"
import { writeFile } from "node:fs/promises"

const result = await parse("document.hwpx")
if (result.success) {
  console.log(result.markdown)
  // result.blocks: structured data; result.metadata: document metadata
}

const hwpx = await markdownToHwpx("# Plan\n\nBody text", {
  gongmun: { preset: "report" },
})
await writeFile("report.hwpx", Buffer.from(hwpx))

Parse options, APIs, forms and rendering examples · From Python or Java: Python SDK, Java SDK

Features

  • Read: Markdown, IR, page text, RAG chunks, local OCR (handwriting included), QR code values in images (--qr-codes), one image format for all images (--image-format png|webp), chart data as tables and SmartArt as lists (--charts, HWP, HWPX, DOCX, PPTX, XLSX)
  • Compare and edit: Block/cell diffs, format-preserving HWPX/HWP patches, new content in a sample's format
  • Create: Markdown → HWPX or HWP (HWP needs npm install @rhwp/core, then -o doc.hwp), government-document presets, department templates (--template) and the look of a report PDF (--layout), TOC page numbers, tables, equations and charts
  • Convert: HWP 5.x → HWPX keeping its formatting (fonts, paragraph shapes, tables, pictures, shapes, equations, headers, footnotes, charts; distribution-protected and track-changes documents included). PDF, DOCX and others become HWPX from what was read with -o document.hwpx
  • Agency packs: Build a house-style pack (.kpack) from a few of your own agency documents and write new documents in that style
  • Fill forms: Fields, click-here controls, two draft templates and seal placement
  • Review: Notation and public-language rules, structure and AI-writing gate, budget calculation checks, block-level lint for open documents (lint-blocks)
  • View and protect: HWPX/HWP previews and region crops, PII masking (opt-in learned model for names and addresses, --model)

Extract Markdown for format-preserving patches with --keep-layout-tables. Unsupported edits are skipped with a reason. Format-preserving editing · Full CLI reference

Validation

Results use fixed corpora and reference criteria. Measured on: default 4.22.14 (2026-10-19) · render layout and statute annexes 4.24.24 (2026-10-30) · HWP → HWPX conversion 4.24.29 (2026-10-31) · OCR 4.24.32 (2026-11-01) · PDF tables 4.24.35 (2026-11-01) · PDF text and opendataloader-bench defaults and OCR on 4.24.50 (2026-11-07) · KoOCR-Bench 4.24.68.

Target Population Result
HWPX 2,424 documents · 10,344 tables Table structure match 10,344/10,344 · 100%
HWP 5.x ↔ HWPX 1,130 pairs · 4,314 tables Paired-document table structure match 100%
HWP 5.x → HWPX conversion 264 pairs saved by Hangul (232 compared attribute by attribute) Attribute match 99.21% · exact 69/232 · text 264/264 · 80 documents checked side by side in Hangul
PDF text 744 pairs Character recall 99.887% · precision 99.685% · reading order 99.398% · word-boundary F1 99.131%
PDF tables 708 pairs · 2,331 tables Detection 99.83% · structure match 98.24% · cell F1 0.9919
HWPX reflow 25,187 multiline paragraphs (12 folders) All line starts match 24,941/25,187 · 99.02%
Nested PDF tables (text layer) 29 documents · 101 tables Structure and cell content 101/101 · 100%
Statute annexes 272 documents · 346 tables HWP 346/346, PDF 343/346 · 99.13%
All PDFs 1,729 scored out of 1,911 documents Text coverage 99.80%
OCR 53 documents · 102 pages · 65 tables CER 0.0237 · character recall 99.33% · table structure 33/65
KoOCR-Bench v2.0c (external) public 877 pages (tables, text, handwriting, order) total 0.906 by default · tables 0.916 · handwriting 0.921 · order 0.914 · heading recall 0.930
opendataloader-bench 200 PDF documents Overall 0.965 with defaults · 0.967 with ocr: true · 0.939 with OCR off (4.22.14)
HWPX render layout 1,565 Hancom PDF pairs (1,508 with matching page counts) · 111,480 text runs · 4,300 images Text position (±1.5pt) 106,904 · 95.9% · image position (±2pt) 4,213 · 98.0%

Table structure, cell content and visual fidelity are separate metrics. The nested-table 100% applies only to these 101 tables, not all PDF parsing or page layout. See benchmark details for scope, exclusions, per-option scores and reproduction.

Recent updates

Latest release: 4.25.36 · 2026-12-01

Version What changed Measured change
4.25.36 redact masks resident/alien registration and phone numbers split across table cells in each cell (HWPX/HWP body and output markdown), plus spaced emails and space-separated account numbers. Large-font form input lines no longer become headings that hid fields from form recognition Split-cell numbers left in body → 0 (residual 0) · 0 new detections across 4,307 corpus docs · 0 heading-line changes across 4,165 HWP/HWPX docs · redact gate passed
4.25.35 HWP 5.x patch no longer writes corrupt files for new paragraphs or rows containing tabs, for templates copied from another section, or when a row and a cell line are added together. Chart value caches are capped at 10,000 points per series (a 400-byte chart could kill Node), and scatter series with different x values are aligned. PDF/OCR text in boxes inside table cells stays in the cell (#257). DOCX footnote/endnote and comment offsets, XLSX fallback shapes, redact model spans, serve returns 503 on file-handle limits (#260) 6 HWP patch failure cases fixed (5 regression tests) · chart memory several GB → 10,000-point cap · OCR robust 2 docs up · score 5,465 · formats 146 · roundtrip 75 · annex 544 docs with 0 drops · PDF glyph normalization FCC 512 pages −5.9% (#259)
4.25.34 Image OCR straightens heavily skewed or rotated photos (receipts etc.) across −90° to 90°, crops to the text area when the photo has a background, and reads upside-down photos. KORDOC_ORT_PROVIDERS=auto runs the OCR, formula and PII models on a GPU (#256) Receipt photo field hits 49.1% → 100% (mean of the first 15 conditions, CER .5022 → .0660) · all 20 conditions 60/60 · 30°·45°·180° 0% → 100% · OCR robustness 11 conditions and KoOCR 869 images unchanged · CUDA 12.4 s → 4.3 s per page
4.25.33 HWPX and HWP 5.x read cell-zone (cellzone) borders, so rows inside the outer frame Hangul draws stay in the table (the visible-table reference uses the same rule). Fixes PDF ruled-grid merges that made two cells overlap and split the same text, and cell line joins across bullet or font changes. HWP patch now edits cells of tables after a table whose trailing empty column was trimmed. Adds the kordoc serve HTTP server (#254), images placed in their table cells with imagePlacement: "flow", correct color order for pageImages (#251), and watch re-saves (#252) HWPX visible tables 10,344 → 10,344 (100% match) · PDF tables exact +1 in 2 docs · PDF coverage .99803 → .99806 (9 docs up) · HWP patch cell edits applied 872 → 912 (1,058 edits), table mapping failures 12 → 0 · ODL 055 .98339 → .98383 · accepted drops 2: 156775701 notes box (PDF page frame), kats UML region recall −0.00002
4.25.32 HWP 5.x patch adds table rows (merged tables too), new headings, and new paragraphs with emphasis. PDF frames and table cells join lines wrapped by the cell width into one paragraph, and the heavy rule ━ in annex fractions is restored. Fixes merged cells in large HWP 3.x tables, seven private HWP 3.x symbols, and shifted row addresses in HWPX HWP table rows: 138 added, 138 removed (150 docs, all open in rhwp) · merged-table rows added 99 · PDF mid-sentence splits 612 → 104 (1,102 docs against the source) · extra line breaks in cells 4,866 → 1,627 · annex text recall 0.914 → 1 (livestock manure act annex 1) · score, formats, roundtrip, annex, gen, PDF text, tables, ODL: 0 drops

See the changelog for earlier releases and details.

FAQ

How do I convert an HWP or HWPX file to Markdown?
Run npx kordoc document.hwp -o document.md. It reads the file directly, without Hancom Office. Convert many files at once with npx kordoc *.hwpx -d ./output.

How do I let Claude, Cursor or another AI agent read Korean documents?
Run npx -y kordoc setup to register the MCP server. The agent can then read, compare and fill HWP, PDF and Excel files from a file path.

Does it work on an air-gapped network?
Yes. KORDOC_OFFLINE=1 blocks all outbound traffic, and OCR runs on the local CPU with no API key. Offline deployment

Can I use it for RAG indexing?
--format chunks emits structure chunks with heading breadcrumbs plus standalone table chunks. Use --table-format gfm (API: tableFormat: "gfm") for tables without HTML. From Python or Java, use the Python SDK or Java SDK.

Can I get OCR line boxes or use another model?
--ocr --ocr-lines --format json exports line boxes and confidence (plus ranked readings with probabilities per line with --ocr-line-candidates 3, and per-character confidence, box and alternatives with --ocr-chars 3); --ocr-det and --ocr-det-long-side select the detector and resolution, and --ocr-rec handwriting|auto selects the handwriting recognizer. --page-images png also returns the page the OCR path read as an image. OCR lines and models

Documentation and security

Star History

Star History Chart

About the Author

A local civil servant in Korea. Built this after seven years of wrestling HWP files at the Gwangjin-gu District Office in Seoul. Validated on thousands of real government documents across five public-sector projects.

License: MIT