<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yixiang xiao</title>
    <description>The latest articles on DEV Community by yixiang xiao (@yixiang_xiao_7e85b6ed0d35).</description>
    <link>https://dev.to/yixiang_xiao_7e85b6ed0d35</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4193117%2Fda40ce37-10e6-4875-920a-781058ccdc77.png</url>
      <title>DEV Community: yixiang xiao</title>
      <link>https://dev.to/yixiang_xiao_7e85b6ed0d35</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yixiang_xiao_7e85b6ed0d35"/>
    <language>en</language>
    <item>
      <title>Building a Browser-Based Excel Editor with Next.js and Univer</title>
      <dc:creator>yixiang xiao</dc:creator>
      <pubDate>Sat, 07 Nov 2026 23:32:18 +0000</pubDate>
      <link>https://dev.to/yixiang_xiao_7e85b6ed0d35/building-a-browser-based-excel-editor-with-nextjs-and-univer-15fb</link>
      <guid>https://dev.to/yixiang_xiao_7e85b6ed0d35/building-a-browser-based-excel-editor-with-nextjs-and-univer-15fb</guid>
      <description>&lt;p&gt;Opening a spreadsheet, fixing a few cells, and downloading the result sounds like a small task. Building a browser application that handles that workflow involves more than putting an editable grid on a page.&lt;/p&gt;

&lt;p&gt;An Excel workbook carries formulas, formatting, merged cells, multiple sheets, and sometimes charts or pivot tables. Those details need to survive the trip through the editor.&lt;/p&gt;

&lt;p&gt;I'm building &lt;a href="https://workbookeditor.com" rel="noopener noreferrer"&gt;Workbook Editor&lt;/a&gt;, a browser-based spreadsheet editor built with Next.js, React, and Univer. This article covers three parts of its implementation: file conversion, loading the editor, and recovering local work.&lt;/p&gt;

&lt;h2&gt;
  
  
  The architecture: separate the grid from the file format
&lt;/h2&gt;

&lt;p&gt;The project gives different libraries different jobs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Next.js and React&lt;/td&gt;
&lt;td&gt;Pages, navigation, and application UI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Univer&lt;/td&gt;
&lt;td&gt;The spreadsheet editing experience&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ExcelJS&lt;/td&gt;
&lt;td&gt;The main XLSX import and export path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SheetJS&lt;/td&gt;
&lt;td&gt;The XLS, CSV, and TSV conversion path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IndexedDB&lt;/td&gt;
&lt;td&gt;Local recovery snapshots and version history&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Univer provides the interactive workbook: cells, selection, formatting controls, and spreadsheet operations. The application registers presets for features such as sorting, filtering, data validation, and find and replace.&lt;/p&gt;

&lt;p&gt;The file conversion layer connects that editing model to the files people bring with them.&lt;/p&gt;

&lt;p&gt;For XLSX files, the basic flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Local file
    ↓
ExcelJS workbook
    ↓
Application adapter
    ↓
Univer workbook
    ↓
User edits
    ↓
Application adapter + export preservation steps
    ↓
Downloaded XLSX file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keeping conversion in a separate module makes the boundary explicit. UI code can work with the editor model, while the adapter handles differences in how workbook features are represented.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing values is only the beginning
&lt;/h2&gt;

&lt;p&gt;A useful adapter has to translate more than cell contents.&lt;/p&gt;

&lt;p&gt;The XLSX adapter handles values and formulas alongside fonts, fills, borders, number formats, alignment, merged cells, row heights, column widths, and sheet metadata.&lt;/p&gt;

&lt;p&gt;Even dimensions require conversion. The implementation translates column widths into pixel dimensions for the editor and converts them back during export. Those calculations are approximations: a workbook's appearance also depends on font metrics and rendering behavior.&lt;/p&gt;

&lt;p&gt;This is why “the file opened” is a narrow measure of compatibility. The more useful question is what happens after someone opens a workbook, edits it, exports it, and opens the result again.&lt;/p&gt;

&lt;p&gt;The project also uses a separate adapter for XLS, CSV, and TSV. These formats have different capabilities, so the conversion paths have different expectations. CSV, for example, cannot carry a workbook's styling or multiple worksheets.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preserve workbook parts outside the main conversion path
&lt;/h2&gt;

&lt;p&gt;Some Excel features need handling beyond the main ExcelJS conversion path.&lt;/p&gt;

&lt;p&gt;The project includes a preservation layer for native chart, pivot, and shape parts. During import, it captures relevant parts from the original XLSX package and stores serialized information with the workbook's resources. During export, it attempts to restore those parts into the generated package.&lt;/p&gt;

&lt;p&gt;That adds a second path alongside normal cell conversion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Original XLSX parts → captured resources → export restoration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Preserving a feature and editing it are separate capabilities. Keeping an original workbook part does not automatically give the browser editor complete control over that feature.&lt;/p&gt;

&lt;p&gt;Restoration also has conditions. Sheet changes and drawing conflicts can affect whether an original part can be restored. This approach extends compatibility, but it does not establish complete Excel fidelity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Load the spreadsheet engine when it is needed
&lt;/h2&gt;

&lt;p&gt;The application includes both content pages and an interactive editor. They have different loading needs.&lt;/p&gt;

&lt;p&gt;The editor component uses a client-side dynamic import with server rendering disabled. Its loading state displays a message and navigation links while the interactive component loads.&lt;/p&gt;

&lt;p&gt;There is another asynchronous boundary inside the editor: Univer setup lives in a dedicated factory module, which the editor imports dynamically.&lt;/p&gt;

&lt;p&gt;That module centralizes the engine's presets, styles, and locale configuration. The separation is intended to keep the engine's dependencies apart from frequently changed application code and improve opportunities for browser caching.&lt;/p&gt;

&lt;p&gt;It is a loading strategy, not a performance measurement. Bundle output and cache behavior still need inspection to establish what a particular release actually delivers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep recovery data in the browser
&lt;/h2&gt;

&lt;p&gt;For the local-file editing path, the application reads file bytes in the browser and converts them into the editor's workbook model.&lt;/p&gt;

&lt;p&gt;Recovery storage follows the same local approach. The application stores a current snapshot and a separate version history in IndexedDB.&lt;/p&gt;

&lt;p&gt;Versions include metadata such as their timestamp, source, and affected sheets. The code distinguishes automatic versions, manual versions, and versions captured before importing content or restoring an earlier state.&lt;/p&gt;

&lt;p&gt;History also needs limits. The retention policy keeps recent versions, thins older entries into time buckets, and applies count and storage caps. Users can pin a limited number of versions.&lt;/p&gt;

&lt;p&gt;These snapshots help recover work in the same browser. Exporting a file remains useful for keeping a separate copy, since browser storage can be cleared.&lt;/p&gt;

&lt;h2&gt;
  
  
  Small tools alongside the full editor
&lt;/h2&gt;

&lt;p&gt;The project also includes focused spreadsheet utilities: removing duplicate rows, trimming whitespace, comparing files, and converting between formats such as XLSX, JSON, and Markdown.&lt;/p&gt;

&lt;p&gt;Those tools provide shorter paths for tasks that do not require a full editing session. Someone who only needs a format conversion can start with that operation directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this project has taught me
&lt;/h2&gt;

&lt;p&gt;The visible grid is one part of a spreadsheet application. Much of the implementation lives at its boundaries: converting workbook models, preserving file parts, loading large dependencies, and retaining enough local history to recover from mistakes.&lt;/p&gt;

&lt;p&gt;Separating those responsibilities makes the application easier to reason about. It also makes compatibility limits easier to describe precisely.&lt;/p&gt;

&lt;p&gt;You can try the project at &lt;a href="https://workbookeditor.com" rel="noopener noreferrer"&gt;workbookeditor.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you've built spreadsheet tooling, which workbook feature has been the hardest to preserve through an import-and-export cycle?&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How We Ran 14 Document Format Conversions in a Browser Tab — Pandoc WASM + Two Rust Engines + A SheetJS Sidecar</title>
      <dc:creator>yixiang xiao</dc:creator>
      <pubDate>Mon, 26 Oct 2026 08:53:55 +0000</pubDate>
      <link>https://dev.to/yixiang_xiao_7e85b6ed0d35/how-we-ran-14-document-format-conversions-in-a-browser-tab-pandoc-wasm-two-rust-engines-a-d3n</link>
      <guid>https://dev.to/yixiang_xiao_7e85b6ed0d35/how-we-ran-14-document-format-conversions-in-a-browser-tab-pandoc-wasm-two-rust-engines-a-d3n</guid>
      <description>&lt;p&gt;There is a category of web tools I will call &lt;strong&gt;document converters&lt;/strong&gt; — the ones that take a Word file or a PDF and give you Markdown or HTML back. They are everywhere. And they are almost all bad.&lt;/p&gt;

&lt;p&gt;The problem is not that the conversion quality is bad in absolute terms (though it often is — lost table borders, heading hierarchies flattened to bold text, footnotes silently dropped). The problem is structural: every converter falls into one of two failure modes. Either it is a simple HTML-to-Markdown transformer that cannot read binary document formats at all, or it is a mature tool with real parsing logic that you have to install on your machine.&lt;/p&gt;

&lt;p&gt;Pandoc is the gold standard of the second category. It reads 14 document formats and writes 8 more. It handles citations, Lua filters, custom templates, footnotes, and arbitrary nesting levels of headings and lists. And you cannot run it in a browser tab.&lt;/p&gt;

&lt;p&gt;Or can you?&lt;/p&gt;

&lt;h2&gt;
  
  
  What we built
&lt;/h2&gt;

&lt;p&gt;We ran the full Pandoc engine — the Haskell codebase, not a reimplementation — compiled to WebAssembly, inside a Web Worker, on a site that converts Word, PDF, EPUB, ODT, RST, MediaWiki, Org, and seven more document formats into Markdown, HTML, RST, LaTeX, or back to docx. Everything runs locally in your browser. Nothing is uploaded.&lt;/p&gt;

&lt;p&gt;The story of how that works is the story of three engines, a virtual file system, and a lot of cache engineering. Let me walk through the parts that were not obvious.&lt;/p&gt;

&lt;h2&gt;
  
  
  Engine 1: Pandoc (GHC → WASM, 58 MB)
&lt;/h2&gt;

&lt;p&gt;Pandoc does not have a browser build. The project is written in Haskell and is distributed as CLI binaries for each platform. Enter &lt;a href="https://github.com/krakenjs/pandoc-wasm" rel="noopener noreferrer"&gt;&lt;code&gt;pandoc-wasm&lt;/code&gt;&lt;/a&gt; — the result of cross-compiling Pandoc with GHC's WebAssembly backend. The output is a 58 MB &lt;code&gt;.wasm&lt;/code&gt; binary that exposes Pandoc's full &lt;code&gt;convert()&lt;/code&gt; function as a JavaScript promise.&lt;/p&gt;

&lt;p&gt;This is not a subset. It is not a port that "covers the common cases." It is the same codebase that runs in the CLI. When Pandoc reads a &lt;code&gt;.docx&lt;/code&gt; file, it does so with exactly the same XML parser and document model that ships in the installer. When it writes GFM Markdown with pipe tables and footnotes, it uses the same writer code path.&lt;/p&gt;

&lt;p&gt;The trade-off is the size. 58 MB is not something you want to ship on first paint. More on that in a moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Engine 2: pdf-inspector (Rust → WASM, 6 MB)
&lt;/h2&gt;

&lt;p&gt;Pandoc does not have a PDF reader. It has never had one. Pandoc's approach to PDF has always been "let some other tool extract text first, then hand me the text."&lt;/p&gt;

&lt;p&gt;For a browser-based pipeline that is unacceptable — we cannot shell out to &lt;code&gt;pdftotext&lt;/code&gt;. So we added a second engine: &lt;a href="https://github.com/firecrawl/pdf-inspector" rel="noopener noreferrer"&gt;&lt;code&gt;@firecrawl/pdf-inspector-wasm&lt;/code&gt;&lt;/a&gt;, a Rust library compiled to WASM that reads PDF layouts and produces structured Markdown directly. It handles multi-column reading order, table detection, heading inference, and flags pages that appear to be image-only (scanned PDFs). The WASM binary is ~6 MB and loads on-demand — only when the first PDF file reaches the worker.&lt;/p&gt;

&lt;p&gt;When the user selects Markdown as the output format, pdf-inspector's Markdown goes straight through. When they select HTML, RST, LaTeX, or docx, the pipeline hands pdf-inspector's Markdown output to Pandoc's corresponding writer as a second pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Engine 3: SheetJS (470 KB, lazy chunk)
&lt;/h2&gt;

&lt;p&gt;Pandoc also has no &lt;code&gt;.xlsx&lt;/code&gt; reader. Same problem, different engine: we added &lt;a href="https://sheetjs.com/" rel="noopener noreferrer"&gt;&lt;code&gt;xlsx&lt;/code&gt;&lt;/a&gt;, bundled into the worker as a separate lazy chunk. The pipeline for Excel files is: SheetJS parses workbook → we flatten merged cells and convert each sheet to an HTML table → the combined HTML document gets fed to Pandoc with &lt;code&gt;from: html&lt;/code&gt; so Pandoc's Markdown writer produces proper pipe tables.&lt;/p&gt;

&lt;p&gt;Why not use SheetJS alone? Because SheetJS produces HTML tables, not semantic Markdown documents. Pandoc's writer handles heading detection (we wrap multi-sheet workbooks with &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; headers per sheet), image extraction from embedded files, and GFM extensions correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Engine 4: OCR (pdfjs-dist + tesseract.js)
&lt;/h2&gt;

&lt;p&gt;Image-only PDFs and scanned documents are a fourth pipeline — pdfjs-dist renders each page to a canvas at 2× scale, tesseract.js recognizes text with language packs loaded on-demand from CDN, and the result goes through &lt;code&gt;pandoc convert()&lt;/code&gt; as a Markdown source. We added structured mode that reads tesseract's bounding boxes and reconstructs GFM tables from column-gap clustering.&lt;/p&gt;

&lt;p&gt;This one does hit a CDN (jsDelivr) for language packs and the tesseract core — we document this transparently. The rest of the pipeline stays local.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cache architecture (why 58 MB does not break the site)
&lt;/h2&gt;

&lt;p&gt;A 58 MB download on first visit would kill any conversion site. We solved this with a three-tier cache that loads Pandoc progressively:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;IndexedDB compiled module cache.&lt;/strong&gt; &lt;code&gt;WebAssembly.Module&lt;/code&gt; objects are structured-cloneable and can be stored in IndexedDB on Chrome, Edge, and Firefox. After the first compile (which takes tens of seconds on a mid-range laptop), we serialize the compiled module to IDB. On the next visit, we deserialize it — that takes 1-2 seconds and skips compilation entirely. Safari is the one browser that throws &lt;code&gt;DataCloneError&lt;/code&gt; when you try to store a &lt;code&gt;WebAssembly.Module&lt;/code&gt;, so all IDB write failures silently fall through to the next tier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cache API byte cache.&lt;/strong&gt; If IDB has no compiled module (first visit or Safari), we check the Cache API for the raw &lt;code&gt;pandoc.wasm&lt;/code&gt; bytes. Cache API is available on all modern browsers in secure contexts. A cache hit means we load the 58 MB from disk (instant) and proceed to compilation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Streaming download with progress.&lt;/strong&gt; If both caches miss, we fetch &lt;code&gt;pandoc.wasm&lt;/code&gt; with &lt;code&gt;res.body.getReader()&lt;/code&gt; and stream it in 100ms-throttled progress updates to the UI, then write it back to Cache API for next time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The load progress bar the user sees has three phases: &lt;code&gt;download&lt;/code&gt;, &lt;code&gt;compile&lt;/code&gt;, and &lt;code&gt;ready&lt;/code&gt;. A returning visitor on Chrome will almost always jump straight to &lt;code&gt;ready&lt;/code&gt; because either the IDB compiled module or the Cache API bytes are already there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtual file system (the trick that makes Pro features work)
&lt;/h2&gt;

&lt;p&gt;Pandoc's &lt;code&gt;convert()&lt;/code&gt; function takes an options object and a map of virtual files. This is how WASM Pandoc handles anything that the CLI would read from disk — bibliography files, CSL style sheets, Lua filter scripts, custom templates. We fixed the file names and mount them as Blobs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;refs.bib     → citations bibliography
style.csl    → citation style file
filter.lua   → custom Lua filter
custom-template.txt → standalone template
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the user enables citations with a &lt;code&gt;.bib&lt;/code&gt; file and a CSL style sheet, we set &lt;code&gt;opts.citeproc = true&lt;/code&gt;, &lt;code&gt;opts.bibliography = "refs.bib"&lt;/code&gt;, &lt;code&gt;opts.csl = "style.csl"&lt;/code&gt;, and add both Blobs to the files map. Pandoc runs citation processing entirely inside the WASM sandbox, with zero network calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Worker isolation (serially, because Pandoc is not thread-safe)
&lt;/h2&gt;

&lt;p&gt;All of this runs inside a single Web Worker. The main thread creates it once on first use with &lt;code&gt;new Worker(new URL("./pandoc.worker.ts", import.meta.url), { type: "module" })&lt;/code&gt; and communicates through a promise-based queue.&lt;/p&gt;

&lt;p&gt;One important detail: &lt;code&gt;pandoc-wasm&lt;/code&gt;'s &lt;code&gt;convert()&lt;/code&gt; is not guaranteed to be concurrency-safe. We serialize every call through a promise chain — the worker runs one conversion at a time, queueing up new requests with &lt;code&gt;chain = chain.then(() =&amp;gt; handle(req))&lt;/code&gt;. This means a user can upload five files and they convert sequentially, not in parallel. For a single-user browser tool, that is fine.&lt;/p&gt;

&lt;p&gt;Worker lifecycle management has three layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reference counting.&lt;/strong&gt; Components acquire the worker on mount and release on unmount. When the count drops to zero, the worker is still alive (for SPA navigation between pages on the same tab).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visibility change.&lt;/strong&gt; When the user switches tabs (&lt;code&gt;document.visibilityState === "hidden"&lt;/code&gt;) and the reference count is zero, we terminate the worker to free the 58 MB of RAM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transferable ArrayBuffers.&lt;/strong&gt; Every file upload and every conversion result (images, binary docx output) uses transferable ownership — the data moves from main thread to worker without copying. Without this, a 2 MB Word document would be cloned twice.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What we learned
&lt;/h2&gt;

&lt;p&gt;A few things that took longer than expected:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TurboPack wasm handling.&lt;/strong&gt; Next.js 16's bundler tries to treat &lt;code&gt;.wasm&lt;/code&gt; files as build assets and emit them into &lt;code&gt;.next/static/&lt;/code&gt;, breaking the cache strategy (we need a stable &lt;code&gt;/pandoc.wasm&lt;/code&gt; URL). The fix is to never import the wasm directly in source code — always fetch it by absolute URL (&lt;code&gt;/pandoc.wasm&lt;/code&gt;) and bypass the bundler's asset pipeline entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GFM vs CommonMark tables.&lt;/strong&gt; Pandoc's CSV reader produces &lt;code&gt;Para&lt;/code&gt; blocks for table cells by default, which Pandoc's Markdown writer then renders as simple text lines — not pipe tables. The fix is to force the writer to &lt;code&gt;markdown+pipe_tables&lt;/code&gt; when GFM output is requested: &lt;code&gt;--to=markdown+pipe_tables-strikeout-task_lists&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pandoc-wasm concurrent calls.&lt;/strong&gt; We initially launched two workers (one for PDF, one for everything else) and got intermittent silent failures. Serializing all calls through one worker fixed it. The library does not advertise this constraint prominently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cell dates in Excel.&lt;/strong&gt; We initially used &lt;code&gt;cellDates: true&lt;/code&gt; when reading Excel files, which caused date values to be reformatted in the output. Switching to &lt;code&gt;raw: false&lt;/code&gt; makes SheetJS prefer &lt;code&gt;cell.w&lt;/code&gt; — the display string Excel cached when the file was last saved — which is exactly what the user sees in the spreadsheet.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you want to try it
&lt;/h2&gt;

&lt;p&gt;We built this as a public tool at &lt;a href="https://wordtomarkdown.com" rel="noopener noreferrer"&gt;wordtomarkdown.com&lt;/a&gt;. The core Pandoc converter is at &lt;a href="https://wordtomarkdown.com/pandoc/" rel="noopener noreferrer"&gt;/pandoc/&lt;/a&gt; and it supports all 14 input formats. For a deeper dive on why we kept Pandoc as the core engine rather than switching to simpler libraries like mammoth or Turndown, see our &lt;a href="https://wordtomarkdown.com/en/articles/pandoc-alternatives/" rel="noopener noreferrer"&gt;Pandoc alternatives write-up&lt;/a&gt;. If you want the side-by-side comparison against what a naive converter gets wrong, our &lt;a href="https://wordtomarkdown.com/en/vs/pandoc/" rel="noopener noreferrer"&gt;Pandoc vs. browser-native page&lt;/a&gt; has the benchmarks.&lt;/p&gt;

&lt;p&gt;Everything documented here is open source by the upstream engines (pandoc-wasm: MIT, pdf-inspector-wasm: MIT, SheetJS: Apache-2.0, tesseract.js: Apache-2.0) and our own pipeline code is straightforward TypeScript you can read through the &lt;a href="https://wordtomarkdown.com/en/verify/" rel="noopener noreferrer"&gt;repository structure&lt;/a&gt; page.&lt;/p&gt;

</description>
      <category>webassembly</category>
      <category>pandoc</category>
      <category>browser</category>
      <category>haskell</category>
    </item>
    <item>
      <title>Running Pandoc in the Browser: WebAssembly, Web Workers, and a 58 MB Module</title>
      <dc:creator>yixiang xiao</dc:creator>
      <pubDate>Tue, 20 Oct 2026 11:04:41 +0000</pubDate>
      <link>https://dev.to/yixiang_xiao_7e85b6ed0d35/running-pandoc-in-the-browser-webassembly-web-workers-and-a-58-mb-module-4hia</link>
      <guid>https://dev.to/yixiang_xiao_7e85b6ed0d35/running-pandoc-in-the-browser-webassembly-web-workers-and-a-58-mb-module-4hia</guid>
      <description>&lt;p&gt;Every "convert my document" tool I've tried has the same shape: you pick a file, it uploads somewhere, a server does the work, you get a download link back. That's fine for public data. It's a much worse deal when the file is a contract, a manuscript, a medical record, or anything else you'd rather not hand to a stranger's S3 bucket.&lt;/p&gt;

&lt;p&gt;So I built a Word→Markdown converter that never uploads anything. It runs the real Pandoc engine, compiled to WebAssembly, inside a browser tab. Here's what that actually took.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Pandoc, and not an HTML pipeline
&lt;/h2&gt;

&lt;p&gt;The obvious approach for &lt;code&gt;.docx&lt;/code&gt; → Markdown is to parse the OOXML into HTML and then walk the HTML into Markdown. That's what most library-based solutions do, and it works for simple documents.&lt;/p&gt;

&lt;p&gt;It falls apart on the things that make Word documents &lt;em&gt;Word documents&lt;/em&gt;: footnotes, cross-references, citation fields, equation markup, tracked formatting. By the time you've flattened all of that to HTML, the semantics are gone — you're walking a DOM that no longer knows what a footnote is.&lt;/p&gt;

&lt;p&gt;Pandoc takes a different route. It parses each format into a typed abstract syntax tree, then writes that AST back out in whatever target format you ask for. Nothing gets flattened prematurely. That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Footnotes stay footnotes, with their original numbering&lt;/li&gt;
&lt;li&gt;Citations survive as citation AST nodes (and can be processed by a CSL processor)&lt;/li&gt;
&lt;li&gt;Math survives as math, not as a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; with a font-family&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One engine covers the whole matrix.&lt;/strong&gt; The same binary reads docx, odt, epub, html, latex, rst, org, csv, tsv, mediawiki, docbook, opml, ipynb and Markdown, and writes Markdown, HTML, reStructuredText and LaTeX&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last point is the real argument. I don't maintain fourteen readers and four writers — I maintain one integration against one very good engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compiling Pandoc to WebAssembly
&lt;/h2&gt;

&lt;p&gt;Pandoc is a Haskell program. The official WASM build exists, and it works, and it is &lt;strong&gt;large&lt;/strong&gt; — around 58 MB once you include the engine and the data files it needs.&lt;/p&gt;

&lt;p&gt;58 MB is a non-starter if you load it on page load. Nobody is going to sit through that to &lt;em&gt;look&lt;/em&gt; at a tool. So:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Load it lazily, on intent.&lt;/strong&gt; The module starts downloading when the user actually drops a file or hits convert — not when the page renders. The landing page stays instant; the cost is paid by people who are already committed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run it in a Web Worker.&lt;/strong&gt; Compiling and executing 58 MB of WASM on the main thread will lock the UI solid. In a worker, the page stays responsive and the user can keep scrolling, reading, or cancel.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part everyone underestimates: compilation, not download
&lt;/h2&gt;

&lt;p&gt;Here's the thing I got wrong at first. I assumed the network transfer would be the bottleneck. It isn't. Downloading 58 MB is a few seconds on a decent connection. &lt;strong&gt;Compiling it is the slow part&lt;/strong&gt; — &lt;code&gt;WebAssembly.compile()&lt;/code&gt; on a module that size takes real time, every time, on every page load.&lt;/p&gt;

&lt;p&gt;The fix is to cache the &lt;em&gt;compiled&lt;/em&gt; artifact, not the bytes. &lt;code&gt;WebAssembly.Module&lt;/code&gt; is structured-cloneable, so you can hand it to IndexedDB and get it back later without recompiling:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;IndexedDB&lt;/strong&gt; — look up the previously compiled &lt;code&gt;WebAssembly.Module&lt;/code&gt; and instantiate it directly. No download, no compile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache API&lt;/strong&gt; — if IDB has nothing, read the raw bytes from the HTTP cache and compile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streaming download&lt;/strong&gt; — last resort, fetch and stream-compile.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The load order is exactly that chain, and the first conversion is the only one that pays full price. Every conversion after that starts from a ready-to-instantiate module.&lt;/p&gt;

&lt;p&gt;Safari is the wrinkle: it won't let you persist a compiled module, so that step silently falls back to re-downloading and recompiling. The feature degrades, it doesn't break — which is the right behaviour, but it's worth knowing if you're benchmarking.&lt;/p&gt;

&lt;p&gt;One maintenance note: when you upgrade the WASM build, &lt;strong&gt;bump the database name&lt;/strong&gt;. Otherwise you'll serve a stale compiled module from the previous version, and you'll spend an afternoon debugging a bug you already fixed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring files through a virtual filesystem
&lt;/h2&gt;

&lt;p&gt;Pandoc is a CLI program. It expects real paths. So the integration is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write the uploaded &lt;code&gt;File&lt;/code&gt; into the WASI virtual filesystem at an input path&lt;/li&gt;
&lt;li&gt;Run Pandoc against that path with the right reader and writer flags&lt;/li&gt;
&lt;li&gt;Read the resulting bytes back out of the virtual filesystem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of the fiddly work lives in the option mapping. A couple of examples that cost me time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pandoc's&lt;/strong&gt; &lt;strong&gt;&lt;code&gt;markdown&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;writer is not GitHub-flavoured Markdown.&lt;/strong&gt; Turn on GFM input and produce &lt;code&gt;markdown&lt;/code&gt; output, and you get a &lt;em&gt;simple table&lt;/em&gt; — a Pandoc construct that GitHub renders as literal text, not a table. For CSV and TSV sources you have to target the &lt;code&gt;gfm&lt;/code&gt; writer explicitly or the table comes out broken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--extract-media&lt;/code&gt;&lt;/strong&gt; &lt;strong&gt;only makes sense for container formats&lt;/strong&gt; (docx, odt, epub, notebooks). Pass it for a plain-text source and it's at best a no-op, at worst confusing. Gate the option on the source format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Format" flags are not binary switches.&lt;/strong&gt; &lt;code&gt;markdown&lt;/code&gt; has a pile of extensions (&lt;code&gt;+footnotes&lt;/code&gt;, &lt;code&gt;+pipe_tables&lt;/code&gt;, &lt;code&gt;-raw_html&lt;/code&gt;, …). Getting a sane default set per source format matters more than any single flag.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The honest trade-off
&lt;/h2&gt;

&lt;p&gt;There is one thing the browser build genuinely cannot do: Pandoc's LaTeX → PDF path needs a LaTeX engine, and there isn't a practical one in WASM.&lt;/p&gt;

&lt;p&gt;Rather than pretend, Markdown→PDF goes through the browser's own print pipeline with paged CSS (A4, page breaks, margins). You get real, selectable text and a proper print dialog — with none of the layout control a real LaTeX template would give you. If you need publication-grade typesetting, use the CLI. If you need "this Markdown should be a readable PDF right now, offline, without installing anything", this is fine.&lt;/p&gt;

&lt;p&gt;Being explicit about that limitation has been more useful than any feature I've shipped. People who need LaTeX know they need LaTeX; everyone else gets a working PDF.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell someone starting this
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pick the engine first, and pick the one with the best AST.&lt;/strong&gt; Client-side pipelines live or die on fidelity, and fidelity is decided before you write any UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never load the engine eagerly.&lt;/strong&gt; Two-stage loading (shell → engine) is the only way a large WASM dependency works in a public tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache the compiled module, not the binary.&lt;/strong&gt; It's the single biggest performance win, and it's a dozen lines of IndexedDB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the worker boundary clean.&lt;/strong&gt; Everything runs in the worker; the UI only sends a job and renders a result. It also makes cancellation and batch conversion straightforward.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I put this into &lt;a href="https://wordtomarkdown.com" rel="noopener noreferrer"&gt;wordtomarkdown.com&lt;/a&gt; — free, no account, nothing uploaded. If you're building something similar (or fighting the same WASM caching problems), I'd be glad to compare notes in the comments.&lt;/p&gt;

</description>
      <category>webassembly</category>
      <category>javascript</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
