npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cloudflare-docx-parser

v1.0.6

Published

A lightweight library to parse .docx files in Cloudflare Workers

Readme

cloudflare-docx-parser

A lightweight library to parse Microsoft Word (.docx) files in Cloudflare Workers. This package is written in TypeScript and extracts plain text by unzipping .docx files (which are essentially ZIP archives) and parsing their XML content.

Table of Contents

Overview

cloudflare-docx-parser is designed for Cloudflare Workers and other environments that do not have support for Node.js or browser-specific APIs. It leverages:

  • fflate for unzipping the .docx file.
  • fast-xml-parser for parsing XML content within the document.

This makes it an excellent choice for extracting text from docx files in edge environments or serverless functions.

Features

  • Cloudflare Compatibility: Works in Cloudflare Workers using only standard Web APIs.
  • TypeScript Support: Provides full TypeScript support and type declarations.
  • Simple API: One function, parseDocx, to extract plain text from a given .docx file.
  • Lightweight: Uses fast, lightweight libraries that run efficiently in edge environments.

Installation

Install the package with npm:

npm install cloudflare-docx-parser

Usage

Below is an example of how to use the package in your project. This example is especially suited for Cloudflare Workers.

Example Worker Code

import { parseDocx } from "cloudflare-docx-parser";

try {
  // Read the .docx file from the request body
  const fileBuffer = await request.arrayBuffer();
  // Parse the .docx and extract plain text
  const extractedText = await parseDocx(fileBuffer);

  return new Response(extractedText, {
    headers: { "Content-Type": "text/plain" },
  });
} catch (error: any) {
  return new Response(error.message, { status: 400 });
}

Bundling

For deployment in Cloudflare Workers, bundle the code using a tool such as esbuild.

Bundling Example using esbuild

Add a build script to your package.json:

"scripts": {
  "build": "esbuild src/index.ts --bundle --minify --platform=browser --format=esm --outfile=dist/index.js"
}

Then run:

npm run build

The output bundle will be generated at dist/index.js.

TypeScript Support

The package is written in TypeScript and includes type declarations. Ensure your tsconfig.json is similar to the following for best compatibility:

{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"declaration": true,
"outDir": "./dist",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}

Testing with Cloudflare Workers

You can test the solution in a Cloudflare Worker by using Cloudflare Wrangler.

Steps to Test

  1. Install Wrangler:
npm install -g @cloudflare/wrangler
  1. Initialize a new Worker Project:
wrangler init --name cloudflare-docx-parser
  1. Integrate cf-docx-parser:

Use the example provided above in your Worker script.

  1. Run Locally:
wrangler dev

Contributing

Contributions, bug reports, and feature requests are welcome! Please submit a PR or open an issue on the GitHub repository.

License

This project is licensed under the MIT License.