Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mammoth

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mammoth

Convert Word documents from docx to simple HTML and Markdown

  • 1.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
341K
increased by10.23%
Maintainers
1
Weekly downloads
 
Created

What is mammoth?

Mammoth is an npm package designed to convert .docx documents into HTML and plain text. It focuses on generating clean, simple HTML that is free from inline styles and other unnecessary elements.

What are mammoth's main functionalities?

Convert .docx to HTML

This feature allows you to convert a .docx file to HTML. The resulting HTML is clean and free from unnecessary inline styles.

const mammoth = require('mammoth');

mammoth.convertToHtml({path: 'path/to/document.docx'})
    .then(function(result){
        var html = result.value; // The generated HTML
        var messages = result.messages; // Any messages, such as warnings during conversion
        console.log(html);
    })
    .catch(function(err) {
        console.error(err);
    });

Convert .docx to plain text

This feature allows you to extract plain text from a .docx file. It is useful for scenarios where you need the text content without any formatting.

const mammoth = require('mammoth');

mammoth.extractRawText({path: 'path/to/document.docx'})
    .then(function(result){
        var text = result.value; // The extracted raw text
        var messages = result.messages; // Any messages, such as warnings during conversion
        console.log(text);
    })
    .catch(function(err) {
        console.error(err);
    });

Convert .docx to Markdown

This feature allows you to convert a .docx file to Markdown. The resulting Markdown is clean and easy to read.

const mammoth = require('mammoth');

mammoth.convertToMarkdown({path: 'path/to/document.docx'})
    .then(function(result){
        var markdown = result.value; // The generated Markdown
        var messages = result.messages; // Any messages, such as warnings during conversion
        console.log(markdown);
    })
    .catch(function(err) {
        console.error(err);
    });

Other packages similar to mammoth

Keywords

FAQs

Package last updated on 18 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc