Marked: A Low-Level Markdown Compiler That Leaves Sanitization to You
A markdown parser and compiler. Built for speed.
At a glance
- What is it?
- Marked is a JavaScript markdown parser and compiler focused on speed and lightweight operation. It works in browsers, servers, and the CLI, but it deliberately does not sanitize output HTML, which is a critical design decision for adopters.
- Who is it for?
- Adopt Marked if you need a fast, lightweight markdown-to-HTML compiler in JavaScript, whether in Node.js, the browser, or a CLI, and you are prepared to handle sanitization yourself. Do not use it if you expect built-in security filtering or if you require support for end-of-life Node.js versions.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- markedjs/marked37,304 ★ · +242
| Repository | 2026-08-18 | 2026-11-15 |
|---|---|---|
| markedjs/marked | 37.1k | 37.3k |
242 Stars in the last 89 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What Marked Actually Does and Who Needs It
Marked solves a narrow problem: converting markdown text into HTML quickly. It is a compiler, not a full document processing system. The README describes it as a 'low-level compiler for parsing markdown without caching or blocking for long periods of time.' That phrasing matters. Marked is built for speed, and it targets developers who need markdown rendering inline, on a server, or in a browser without the overhead of a larger framework. The intended audience is JavaScript developers who want a minimal dependency that does one thing. It is not for end users directly; it is for engineers building tools, chat apps, documentation generators, or static site pipelines. The README emphasizes speed, lightweight size, and support for all markdown features from the supported flavors and specifications. If you need a parser that keeps its footprint small and performs predictably, Marked fits that profile.
The Mechanism: Parsing Without Caching or Blocking
The core mechanism is synchronous parsing of markdown strings into HTML. The README's Node.js example shows a simple import and a single call: marked.parse('# Marked in Node.js'). That function returns an HTML string. The 'low-level' description suggests that Marked does not maintain a cache or a persistent state between calls. Each parse is independent. This design has a direct consequence: repeated parsing of the same input will redo all the work. In a high-throughput server, that could be a performance concern, but it also means no memory is held for caching, which keeps the compiler light. The browser example uses a UMD bundle from a CDN, and the ESM module is also available. The parser walks the markdown tokens and emits HTML, but the README does not detail the internal tokenization algorithm. The key point is that Marked is a straightforward function call, not a streaming parser. For very large documents, the lack of streaming could block the event loop, but the README claims it is designed not to block 'for long periods of time.' That claim is a trade-off: it is fast, but it is still synchronous.
Getting It Running: CLI, Node, and Browser
Installation is straightforward. For the CLI, the command is npm install -g marked. For in-browser use, npm install marked. The CLI accepts stdin and writes to a file with the -o flag. The README shows this example: marked -o hello.html, then typing markdown and ending with Ctrl-D. The output is written to hello.html. You can also run marked --help to see all options. In Node.js, you import the marked object and call marked.parse. The browser path offers two options: a UMD script that exposes a global marked object, or an ESM module import from a CDN. The UMD example uses marked.parse directly. The ESM example imports the marked object and calls marked.parse. Both are simple. One detail worth noting: the README warns that Marked does not sanitize output HTML. That is not a bug; it is a design choice. You must run the output through a sanitizer like DOMPurify. The README even shows the pattern: DOMPurify.sanitize(marked.parse(...)). This is a critical configuration step, not an optional one.
The Sanitization Gap Is a Real Limitation
The most significant limitation is the lack of built-in sanitization. The README issues a strong warning, with emojis and capital letters: 'Marked does not sanitize the output HTML.' That means if your markdown input comes from untrusted users, the generated HTML could contain script tags or event handlers. The recommended fix is to pass the output through DOMPurify, sanitize-html, or insane. This is a genuine failure mode: if you forget to add a sanitizer, you introduce an XSS vulnerability. Marked is the wrong tool for any application where you cannot guarantee a sanitization step downstream. For example, a server-side renderer that sends HTML directly to a browser without post-processing is dangerous. This is not a flaw in the parser itself, but it is a burden on the adopter. The README's warning is clear, but in a fast-moving project, it is easy to miss. So the limitation is structural: Marked's job ends at HTML generation.
Custom Extensions: The Adaptability Trade-Off
Marked supports custom extensions, and the README links to documentation on 'using_advanced' and 'using_pro'. The extension mechanism is a major selling point for teams that need non-standard markdown syntax. The README says Marked is 'easily adaptable with custom extensions.' That sounds promising, but the documentation is not in the README; you have to visit marked.js.org. The extension API likely involves registering custom tokenizers and renderers, but the README does not show an example. That is a documentation gap. The trade-off is that the low-level design gives you control, at the cost of learning the extension documentation. For simple use cases, the default markdown features are enough. For complex ones, you must invest time in the extension API. Compared to a parser like remark, which uses a unified plugin system, Marked's extension approach is more ad hoc. The README does not mention any plugin ecosystem, so expect to write your own logic.
Compatibility and Maintenance Costs
Marked's compatibility policy is strict. The README states that only current and LTS Node.js versions are supported, and end-of-life versions may break at any time. That means if you are running an older Node.js in production, you cannot rely on Marked. This is a maintenance consideration: you must keep your runtime up to date. For browsers, the requirement is 'Baseline Widely Available,' which is a modern standard. This is a reasonable policy for a project that moves fast, but it adds upgrade pressure. The release history shows frequent updates: v18.1.1 (2026-10-12), v18.1.2 (2026-10-26) and v18.1.3 (2026-11-02). That suggests active maintenance, but also a need to track releases. The license is MIT, based on the README's copyright notice, even though the repository metadata says NOASSERTION. The MIT license is permissive, so you can use it in commercial projects. The maintenance cost is mostly about keeping up with version changes and ensuring your sanitization layer remains compatible. The frequent releases could introduce breaking changes, and the repository includes a CHANGELOG.md.
Alternatives and the Real Difference in Approach
The main alternative to Marked is remark, part of the unified ecosystem. Remark uses an abstract syntax tree (AST) and a plugin system. That is a fundamentally different approach. Marked parses directly to HTML with a single function call. Remark first parses markdown into an AST, then you can transform that AST with plugins, and finally you stringify it to HTML. That extra step gives you more control, but it is also more complex. If you need to manipulate the document structure, like extracting headings or converting to other formats, remark is a better fit. Marked is simpler and faster for plain conversion. Another alternative is markdown-it, which is also a synchronous parser but has a plugin system and a built-in typographer. markdown-it is often compared to Marked, and it is generally considered more configurable. The README does not mention these alternatives, but the key difference is that Marked keeps its core minimal and pushes sanitization and extensions to the user. For a quick, dependency-light render, Marked wins. For a full document processing pipeline, you would need more.
Editorial conclusion
Adopt Marked if you need a fast, lightweight markdown-to-HTML compiler in JavaScript, whether in Node.js, the browser, or a CLI, and you are prepared to handle sanitization yourself. Do not use it if you expect built-in security filtering or if you require support for end-of-life Node.js versions. Before adopting, verify that your output pipeline includes a sanitizer like DOMPurify, confirm your Node.js version is current or LTS, and test your custom extensions against the extension API, since Marked's low-level design means you take responsibility for safe output.
Frequently asked questions
What does "marked" mean?
In this repository marked is a markdown parser and compiler, described as built for speed, published on npm as marked and documented at marked.js.org. It is MIT licensed and provides a library entry, a command line binary with a man page, and a browser build. It parses markdown into HTML and does not sanitize that HTML.
Does marked sanitize the HTML it produces?
No. The project states plainly that marked does not sanitize the output HTML and recommends running a sanitize library over the output, naming DOMPurify as the recommended choice, with sanitize-html and insane as alternatives. The documented pattern wraps the parse call inside a sanitize call, so both steps are yours to add.
How do I install marked?
Two lines are documented: npm install -g marked for the command line tool, and npm install marked for use in a project. The browser route is not an npm install at all but a script tag pointing at the UMD build on a CDN, or an ES module import from the same CDN. The CLI reads standard input and writes with an output flag.
Which Node.js versions does marked support?
Only current and LTS Node.js versions, and the project warns that end of life versions may become incompatible at any point in time. For browsers the stated target is the Baseline Widely Available level, so support follows that definition rather than a fixed version list. The current release is v18.1.3, published 2026-11-02.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/markedjs-marked)Star history chart for your README
[](https://hysenlabs.com/projects/markedjs-marked)Was this useful?