Introduction
K2F is a document format for pixel-identical, semantically editable documents. You author meaning as JSON; one reference engine compiles it, and every viewer paints the same output.
Package model
A .K2F file is a ZIP. You edit two layers; k2f pack / compile writes the third:
| Layer | Path | What it is |
|---|---|---|
| Content | content/root.json | Semantic tree: stable id, role, and content. No coordinates, colors, or font sizes. |
| Theme | styles/theme.json | Appearance keyed by role (and optional variant). Fonts live here and under assets/fonts/. |
| Lock | document.K2F.lock | Compiled geometry and paint operations. Viewers and exports paint this. Do not hand-edit. |
manifest.json sets page size and margins; assets/ holds fonts and images. Change content or theme, then relock.
Quick install
pip install k2f
Python 3.9+. Optional: npm i @openk2f/k2f for the web viewer; cargo install k2f for a CLI without Python. For the full author loop (skill folder, init_package.py, pack_verify.py), see Getting started.
Get started
- Getting started — agent skill or CLI, first
.K2F - Format spec — normative contract (container, processing, integrity)
Authoring
- Copy golden nodes from the catalog into
content/root.jsonchildren(keepid: "root"; do not replace the file with a catalog fragment). - Look up allowed keys in Allowed keys, then the matching file under
schema/.
Topic guides:
- Text — paragraphs, headings, lists, inline marks
- Images — embedded bitmaps and SVG
- Tables — inline tables
- Layout — stack and grid
- Theme and fonts — roles, variants, embedded fonts
Reference
- Catalog — packable
ex_*.jsonexamples - Allowed keys — node, theme, and manifest fields
- Format spec
Export
Markdown or JSON → packed .K2F → PDF, PowerPoint, Word, or InDesign. The lock is the source; each file is a drawing of it.
- Export — pipeline and format comparison
- PDF — fillable AcroForm by default
- PowerPoint
- Word
- InDesign
Guides
- Markdown conversion — Markdown ↔ K2F
- Web viewer — embed
<k2f-viewer>(serve packages over HTTP, notfile://)
Permanent publish links (/v/{appearance_hash}) are documented in the K2F Skill (references/publishing.md).
Agents and tools
- K2F Skill —
npx skills add suzheng/k2f --skill k2f; workflows for create, convert, export, and embed · k2f.dev/skills/k2f - Playground — compile and preview in the browser
- Verify — check a
.K2Ffile for integrity banners
Project
- Status and roadmap
- Desktop reader (in development) — native lock executor (same rules as the web viewer)
- Contributing · Security · Compatibility
Contributor internals (engine design, crate map): architecture/. Not part of the authoring path.