The K2F format operates on a dual-state architecture: an editable, declarative semantic JSON tree (State A) and a compiled, pixel stable lock (document.K2F.lock / State C) packaged inside a self-contained ZIP archive. While HTML pairs structural DOM markup with runtime CSS cascading and procedural JavaScript execution—deferring geometry, font rasterization, and line wrapping to client-side browser layout passes (Blink, WebKit, Gecko)—K2F compiles semantic intent into deterministic geometry using a dedicated Rust reference layout engine (k2f_layout), strictly isolating content meaning from visual theme primitives and mandating embedded fonts.

K2F is not a lossless superset of HTML. K2F v0.1 does not import or convert HTML documents (in the Markdown import bridge, raw HTML tags are marked as skipped raw HTML), cannot import PDF documents (PDF_IS_NOT_A_SOURCE), lacks arbitrary Bézier vector art directly in State A, lacks fluid viewport reflow, forbids arbitrary inline CSS or class cascades in State A, and strictly prohibits client-side executable scripting (JavaScript) within document packages. Furthermore, while the k2f.dev website uses HTML for its web chrome, navigation, and documentation, the embedded <k2f-viewer> acts strictly as a lock executor via WebAssembly, painting compiled lock pixels directly to an HTML5 <canvas> (official 2× rasterization) with an overlaid transparent text selection layer, rather than evaluating reflowable DOM or CSS layout passes. All downstream formats exported from K2F (PDF, Word, PowerPoint, InDesign) are unidirectional deliverables rendered from the compiled lock (*_IS_NOT_A_SOURCE) rather than round-trip authoring sources.

At a glance

TopicHTMLK2F
What the file isText markup language (text/html, RFC 2854; WHATWG Living Standard) parsed in memory into a DOM treeDeclarative semantic JSON tree (State A) + compiled render lock (State C) in a self-contained ZIP archive
Primary authoring modelHuman web development (code editors, template frameworks), browser rich-text WYSIWYG editors, CMS platforms, and SSG compilersProgrammatic authoring, inspection, and patching by AI agents and automated code pipelines
Canvas geometry & pagesFluid, continuous canvas with dynamic viewport reflow; lacks native physical page geometry, sheet bounds, or margin boxesExplicit paged canvas geometry (canvas_mode: "paged"), margin definitions, multi-column stacks, containers, and page budgets
Rendering & layout executionRuntime layout calculated client-side by browser rendering engines (Blink, WebKit, Gecko) upon load and resizeAhead-of-time deterministic compilation (f(content, theme) → geometry); viewers paint document.K2F.lock without reflowing text
Pixel-stable pages & fontsNon-pixel-stable; engine rounding variances, OS text rasterizers (Core Text vs DirectWrite vs FreeType), and font fallback shiftsYes — viewers paint the lock directly; mandatory embedded fonts (assets/fonts/) guarantee cross-device pixel stability
Node addressing for AIFragile; elements lack unique IDs; relies on ephemeral CSS classes (Tailwind), generated class hashes, or brittle XPath selectorsMandatory, hierarchical dotted IDs (parent_id.child_type_semantic_name) on every semantic node in State A
Agent edit fidelity & driftHigh fragility; HTML5 parser lenient auto-repair normalizes tags, collapses whitespace, and causes silent DOM driftGit-native Canonical JSON (sorted keys, 2-space indentation) ensures clean semantic diffs; schema-validated via pack_verify
Separation of concernsSeverely blurred in practice; utility CSS classes (Tailwind soup), inline style="..." overrides, and SPA hydration wrappersStrict separation: zero styling on State A nodes; visual primitives live exclusively in styles/theme.json
Theming & global restylingHigh risk of CSS specificity traps (!important, class chains) and cascade side effects breaking unrelated componentsSingle token change in styles/theme.json restyles entire document deterministically upon recompilation without layout drift
Print & paginationIncomplete CSS Paged Media support; no native GCPM margin boxes in browsers; print-to-PDF splits table rows and text linesNative two-pass paged layout compiler with running headers/footers, orphan suppression, and strict vertical page budgets
Document integrity & trustNo native document cryptographic hashing, signing, or tamper evidence; vulnerable to remote CDN asset alteration and link rotDual-hash architecture (content_hash, appearance_hash), Ed25519 signatures, mandatory viewer banner (SIGNED, UNSIGNED, SIGNED_BUT_BROKEN, BROKEN_INTEGRITY, UNLOCKED)
Interactive formsNative HTML5 form elements (<input>, <select>, <textarea>) with DOM event validation and submit handlersNative form_field semantic nodes compile directly into genuine interactive AcroForm PDF exports
Vector graphics & mediaNative inline SVG, <canvas>, WebGL, and remote image/video/audio URLs fetched over the networkForbidden in State A JSON; external vector graphics stored as pre-rendered SVGs or images in /assets/ (local files only)
Multi-format supply chainNative web deliverable; converting to print PDF requires headless Chrome automation; Word/InDesign exports are lossy/heuristicSingle-source lock-drawn exports to PDF (with AcroForms), Microsoft Word (.docx), PowerPoint (.pptx), and InDesign (.idml)
Import / Source of truthUndisputed source of truth for web apps and sites; rarely accepted as binding legal source of truth without converting to PDF.K2F is sole source of truth; K2F v0.1 does not import HTML or PDF (PDF_IS_NOT_A_SOURCE); exports are unidirectional lock renderings (*_IS_NOT_A_SOURCE)

HTML vs K2F: What HTML is good at

HTML is the foundational document and interface standard of the World Wide Web. Its core strengths include:

  • Universal browser ubiquity & zero-friction access: HTML opens natively in every web browser across every desktop operating system, smartphone, tablet, and smart display without requiring plugins, runtime installations, or file unpackers.
  • Fluid, responsive layout across arbitrary viewports: HTML and CSS excel at responsive design through media queries, Flexbox, CSS Grid, and container queries. A single HTML document fluidly adapts from a 320px mobile screen to an ultra-wide 4K desktop monitor without breaking content accessibility.
  • Rich interactivity & dynamic application capabilities: Native integration with JavaScript, the DOM event model, Web Components, HTML5 forms, <canvas>, WebGL, and audio/video streaming allows HTML to power sophisticated interactive applications and dashboards that static document formats cannot match.
  • Decades of accessibility maturity (WAI-ARIA & Screen Readers): The web platform features the computing industry's most advanced accessibility ecosystem. Assistive technologies and screen readers (Apple VoiceOver, NVDA, JAWS) navigate native HTML semantic elements, landmark roles, and ARIA attributes with unmatched fidelity.
  • Web ecosystem & search engine discoverability (SEO): HTML documents are natively discoverable, linked into the global web graph, and indexed by search engine crawlers (Google, Bing).
  • Hyperlinking and deep linking: Native fragment identifiers (#section-id) enable instantaneous deep linking into precise locations within documents across the global Internet.
  • Incremental parsing and progressive streaming: Web browsers parse and display HTML streams incrementally as bytes arrive over the network, rendering above-the-fold content immediately before complete documents or external subresources finish downloading.
  • Ideal medium for portals and documentation chrome: As demonstrated by k2f.dev, HTML is the superior format for website navigation, documentation chrome, interactive comparison matrices, and web application UI shells.

What K2F adds

K2F is engineered for workflows where autonomous AI agents and automated software pipelines require deterministic structure, verifiable rendering, and multi-format delivery:

  • Declarative semantic tree & stable dotted IDs: Every node in State A (content/root.json) carries a mandatory, hierarchical dotted ID (e.g., financials.q3_results.table_revenue, contract.clauses.clause_4_indemnity). AI agents read, patch, diff, and revert specific content nodes with 100% addressable precision by ID, eliminating fragile CSS selectors, complex XPath queries, or heuristic text scraping.
  • Deterministic layout compilation & pixel-stable lock (document.K2F.lock): K2F decouples structural intent from visual geometry. The reference Rust layout engine (k2f_layout) calculates exact physical coordinates using HarfBuzz text shaping (rustybuzz), Unicode line breaking (UAX #14), and IEEE-754 math layout into an immutable render lock (State C). Official viewers (<k2f-viewer>, Desktop Reader) strictly paint the lock plan directly without running layout or reflowing body text in the browser, guaranteeing PDF-grade visual determinism across operating systems.
  • Mandatory embedded fonts: HTML documents frequently rely on system font fallbacks or network web fonts subject to operating system rasterizer discrepancies (Core Text vs. DirectWrite vs. FreeType) and FOUT/FOIT loading delays, causing unexpected line wrapping. K2F mandates complete embedded fonts in assets/fonts/ and strictly prohibits system font fallbacks, ensuring identical rendering on every client.
  • Strict intent-presentation separation & global restyling: HTML mixes content structure with presentational utility classes (Tailwind) and inline styles, exposing AI agents to cascading CSS specificity traps. K2F strictly forbids inline styling on State A nodes; visual attributes are governed entirely by named design primitives in styles/theme.json. A single prompt or theme token restyles an entire document deterministically upon recompilation without layout drift.
  • True document pagination & print budgets: Unlike web browsers that exhibit incomplete support for CSS Paged Media Module Level 3 and lack W3C GCPM margin boxes, K2F natively handles multi-page documents (canvas_mode: "paged"), running headers/footers, orphan suppression, and strict vertical page budgets through a two-pass layout compiler.
  • Dual-hash cryptographic integrity & mandatory viewer banner: Native HTML provides no cryptographic document hashing, signatures, or tamper-evidence mechanisms, leaving archived pages vulnerable to CDN asset tampering and link rot. K2F implements a dual-hash architecture: content_hash hashes the semantic tree, while appearance_hash binds content, theme primitives, embedded fonts, page setup, and the pinned reference engine identity (engine_commit_sha). Official readers enforce a mandatory integrity banner reporting five canonical states (SIGNED, UNSIGNED, SIGNED_BUT_BROKEN, BROKEN_INTEGRITY, UNLOCKED), alongside layout engine discrepancies (ENGINE_MISMATCH).
  • Self-contained ZIP package architecture: A .K2F file bundles manifest metadata, semantic content, themes, and embedded fonts into a single portable container. It suffers no external link rot, no missing font dependencies, and no CDN security vulnerabilities.
  • Automated package verification (pack_verify): Every .K2F package embeds formal JSON schemas (/schema/). Verification utilities (pack_verify, CLI k2f verify) validate structural rules, font coverage, and modifier constraints, allowing AI agents to self-diagnose and repair schema violations before compilation.
  • Native fillable PDF forms (AcroForm): K2F's form_field semantic nodes compile directly into genuine interactive AcroForm PDF fields upon export, bridging agent-generated form logic with universal PDF distribution.
  • Single-source multi-format export pipeline: A single .K2F document compiles once to produce lock-drawn deliverables for PDF (with interactive AcroForms), Microsoft Word (.docx), PowerPoint (.pptx), and Adobe InDesign (.idml).
  • Agent tooling and template ecosystem: K2F provides an official agent skill implementing the agent_v0 authoring dialect and a public Gallery of 469+ templates on k2f.dev with multi-format downloads (.K2F, .docx, .pptx, .idml) without requiring accounts or subscriptions.

When to pick which

  • Pick HTML when:

    • Building responsive websites, web applications, SaaS dashboards, and digital portals that must fluidly reflow across mobile phones, tablets, and desktop displays.
    • Documents require dynamic client-side scripting, interactive state management, audio/video streaming, or complex DOM events.
    • Workflows require maximal web crawler discoverability (SEO), native WAI-ARIA screen reader navigation, and global URL deep-linking.
    • Requiring progressive token-by-token streaming or incremental network rendering for immediate above-the-fold display.
    • Creating website chrome, navigation headers, and documentation portals (such as the web shell of k2f.dev itself).
  • Pick K2F when:

    • Creating formal, paged business documents (reports, contracts, invoices, whitepapers, certificates, planners, or fillable application forms) requiring precise typography, vertical page budgets, and print-ready presentation.
    • Autonomous AI agents and automated code pipelines must programmatically inspect, target, patch, and validate document content using stable dotted node IDs without CSS specificity collisions or fragile XPath scraping.
    • Documents demand cross-device, cross-platform pixel stability via embedded fonts and a compiled geometry lock (document.K2F.lock), eliminating browser-dependent layout variations.
    • Publishing simultaneously from a single source of truth to PDF (with interactive AcroForms), Microsoft Word (.docx), PowerPoint (.pptx), and Adobe InDesign (.idml).
    • Workflows require cryptographic tamper-evidence (content_hash, appearance_hash, Ed25519 signatures) and standardized viewer integrity banners.
  • Complementary roles and coexistence:

    • HTML and K2F serve different layers of digital publishing. Use HTML for the web application shell, navigation chrome, and responsive website (as k2f.dev does), and use K2F for the agent-editable, pixel-stable documents hosted within it. Do not attempt to preview a K2F tree by rendering it as raw HTML flow; use the official WASM <k2f-viewer> or Playground to paint the compiled render lock. Deliverables exported from K2F are unidirectional drawings of the lock, not editable sources of truth (PDF_IS_NOT_A_SOURCE, DOCX_IS_NOT_A_SOURCE, PPTX_IS_NOT_A_SOURCE, IDML_IS_NOT_A_SOURCE). All authoritative structural edits must occur in K2F State A.

Bottom line

For additional details on K2F architecture, explore the technical documentation, review pre-built templates in the Gallery, read why K2F exists, or view the full matrix on Compare.

This comparison is based on publicly available information at the time of writing. Capabilities, pricing, and policies may change; verify details with the relevant provider.