Word documents
Paper-like pages, real image sizes, footnotes, right-to-left paragraphs, zoom, search and printing. Powered by mammoth.js.
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/officetohtmlThe 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.
Paper-like pages, real image sizes, footnotes, right-to-left paragraphs, zoom, search and printing. Powered by mammoth.js.
Slide list or slideshow with autoplay, keyboard navigation and full screen. Charts, tables, shapes and media. Powered by PPTXjs v2.
Excel-like grid with sheet tabs, formula bar, merged cells, column widths, hidden rows and search. Powered by SheetJS and Handsontable.
Selectable text, search with highlights, thumbnails, outline, rotation, hand tool, presentation mode with swipe and pinch zoom. Powered by PDF.js.
A modern image viewer: zoom to the cursor, pinch, pan, rotate, flip, fit and actual size, transparency grid and full screen.
Plain text, Markdown, JSON (pretty printed), XML and source code with line numbers, wrapping and search.
Version 2 is a complete rewrite of the original jQuery plugin.
Converted HTML is sanitised, links are checked, PDF scripts never run and file names are always shown as text.
The core is small. PDF.js, mammoth, SheetJS, Handsontable and PPTXjs load only when a file of that type is opened.
Vanilla JS, React, Vue 3, Angular, jQuery (v1-compatible API) and a <office-viewer> Web Component.
UI in English, Hebrew, Arabic, Spanish, French, German, Russian and Chinese, with full right-to-left support.
Follows the operating system or your setting. Styling uses CSS custom properties that are easy to override.
Printing sends only the document to the printer – not your page, toolbar or navigation.
Keyboard shortcuts, focus styles, ARIA labels and live regions for status and search results.
Unit and DOM tests with Vitest, including regression tests for every security fix.
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<div id="viewer" style="height:600px"></div>
<script src="https://cdn.jsdelivr.net/npm/@meshesha/officetohtml@2/dist/officetohtml.umd.js"></script>
<script>
const viewer = new OfficeToHtml.OfficeViewer("#viewer");
viewer.load("files/presentation.pptx");
</script>import { OfficeViewer } from "@meshesha/officetohtml/react";
export function Preview({ file }) {
return <OfficeViewer src={file} style={{ height: 600 }} onError={(e) => console.error(e)} />;
}<script setup>
import { OfficeViewer } from "@meshesha/officetohtml/vue";
</script>
<template>
<OfficeViewer src="/files/budget.xlsx" style="height:600px" @load="onLoad" />
</template>// main.ts
import { defineOfficeViewerElement } from "@meshesha/officetohtml/angular";
defineOfficeViewerElement();
// component template (add CUSTOM_ELEMENTS_SCHEMA to the component)
// <office-viewer [attr.src]="url" theme="auto" style="height:600px"></office-viewer>// v1 code keeps working:
$("#resolte-contaniner").officeToHtml({ url: "files/demo.pdf" });
// or the v2 API:
$("#viewer").officeViewer({ src: "files/demo.pdf", theme: "dark" });OfficeToHtml is MIT licensed and stands on the shoulders of these excellent open-source projects. Thank you to all their authors and contributors.
PowerPoint rendering, slideshows and charts. By meshesha.
Converts .docx documents to clean HTML. By Michael Williamson.
Reads xlsx, xls, xlsb, ods, csv and many more spreadsheet formats.
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).
Mozilla's PDF renderer and viewer components.
Sanitises the HTML generated from documents. By Cure53.
Fast, small ZIP decompression used for format detection. By 101arrowz.
TypeScript, Vite, Vitest, jsdom, ESLint and Playwright.
Full license texts are in THIRD_PARTY_NOTICES.md.