Version 2 · TypeScript · no jQuery

Office documents, right in the browser.

One Office-like viewer for Word, PowerPoint, Excel, PDF, images and text files. No server, no plugins, no uploads – files never leave the user's device.

npm install @meshesha/officetohtml

Every common format, one API

The file type is detected from the file's content, not just its name. Each format uses the best open-source engine and is shown in a consistent, modern interface.

DOCX

Word documents

Paper-like pages, real image sizes, footnotes, right-to-left paragraphs, zoom, search and printing. Powered by mammoth.js.

docxdocmdotx
PPTX

Presentations

Slide list or slideshow with autoplay, keyboard navigation and full screen. Charts, tables, shapes and media. Powered by PPTXjs v2.

pptxppsxpotx
XLSX

Spreadsheets

Excel-like grid with sheet tabs, formula bar, merged cells, column widths, hidden rows and search. Powered by SheetJS and Handsontable.

xlsxxlsxlsbodscsvtsvnumbers
PDF

PDF files

Selectable text, search with highlights, thumbnails, outline, rotation, hand tool, presentation mode with swipe and pinch zoom. Powered by PDF.js.

pdf

Images

A modern image viewer: zoom to the cursor, pinch, pan, rotate, flip, fit and actual size, transparency grid and full screen.

pngjpggifwebpavifsvgbmp

Text & code

Plain text, Markdown, JSON (pretty printed), XML and source code with line numbers, wrapping and search.

txtmdjsonxmljs…

Built for real applications

Version 2 is a complete rewrite of the original jQuery plugin.

🔒 Secure by default

Converted HTML is sanitised, links are checked, PDF scripts never run and file names are always shown as text.

⚡ Loads what it needs

The core is small. PDF.js, mammoth, SheetJS, Handsontable and PPTXjs load only when a file of that type is opened.

🧩 Any framework

Vanilla JS, React, Vue 3, Angular, jQuery (v1-compatible API) and a <office-viewer> Web Component.

🌍 International

UI in English, Hebrew, Arabic, Spanish, French, German, Russian and Chinese, with full right-to-left support.

🌓 Light & dark

Follows the operating system or your setting. Styling uses CSS custom properties that are easy to override.

🖨️ Prints the document

Printing sends only the document to the printer – not your page, toolbar or navigation.

♿ Accessible

Keyboard shortcuts, focus styles, ARIA labels and live regions for status and search results.

🧪 Tested

Unit and DOM tests with Vitest, including regression tests for every security fix.

Get started in a minute

Pick your setup. See the documentation for every option.

import { OfficeViewer } from "@meshesha/officetohtml";

const viewer = new OfficeViewer("#viewer", { theme: "auto" });
await viewer.load("/files/report.docx"); // URL, File, Blob or ArrayBuffer

Credits & licenses

OfficeToHtml is MIT licensed and stands on the shoulders of these excellent open-source projects. Thank you to all their authors and contributors.

PPTXjs

MIT

PowerPoint rendering, slideshows and charts. By meshesha.

mammoth.js

BSD-2-Clause

Converts .docx documents to clean HTML. By Michael Williamson.

SheetJS Community Edition

Apache-2.0

Reads xlsx, xls, xlsb, ods, csv and many more spreadsheet formats.

Handsontable

Free non-commercial / commercial

The Excel-like data grid. Free for non-commercial and evaluation use; commercial use needs a Handsontable license (or use the built-in "table" engine).

PDF.js

Apache-2.0

Mozilla's PDF renderer and viewer components.

DOMPurify

Apache-2.0 / MPL-2.0

Sanitises the HTML generated from documents. By Cure53.

fflate

MIT

Fast, small ZIP decompression used for format detection. By 101arrowz.

Full license texts are in THIRD_PARTY_NOTICES.md.