Marked.js is a high-performance Markdown parser designed to efficiently convert Markdown text into HTML. It is currently at version 18.0.2 and maintains a very active release cadence, with frequent patch and minor versions often released weekly or bi-weekly, and major versions arriving every few months. Key differentiators include its strong focus on speed, its architecture as a low-level compiler that avoids caching and prolonged blocking operations, and its lightweight footprint. It aims to implement all Markdown features from supported specifications and is versatile, capable of running in browser environments, on a server (Node.js), or via its command-line interface. A critical consideration for users is that Marked.js intentionally does *not* sanitize its HTML output, necessitating the integration of a separate sanitization library like DOMPurify for any security-sensitive applications.
npm install markedVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic Markdown parsing with Marked.js, including critical HTML sanitization using DOMPurify and configuring options.
Upgrade your project's TypeScript version to 6.0.2 or newer, or ensure your tsconfig.json is configured to support the types.
Review custom Marked.js extensions, especially those dealing with lists, tokens, or renderers, and update them to align with the new internal token and renderer structures as documented in the Marked.js extensibility guide.
ALWAYS sanitize the HTML output using a dedicated sanitization library like DOMPurify (recommended) or sanitize-html before rendering it in a browser context. This step is critical for security.
Ensure your Node.js environment is always an actively maintained LTS or current release. Refer to the official Node.js releases page for up-to-date information.
Regularly update Marked.js to the latest stable version to benefit from security patches and performance improvements. Avoid crafting custom regular expressions for Markdown parsing without thorough ReDoS testing.
Change your import statement to `import { marked } from 'marked';` or `import { parse } from 'marked';` for ESM environments.For Node.js/bundlers using ESM, ensure you use `import { marked } from 'marked';` and then call `marked.parse()`. If using the browser UMD bundle (`marked.umd.js`), the `marked` global object should have the `parse` method directly.Integrate a robust HTML sanitization library, such as DOMPurify, and run the `marked.parse()` output through it before rendering. Example: `DOMPurify.sanitize(marked.parse(input))`.
No dependency data recorded yet.