snarkdown
A dead-simple, dependency-free Markdown-to-HTML parser that weighs about 1kb gzipped.
Repository Health
Technical Analysis
Snarkdown is a minimal Markdown-to-HTML parser built around a single regular expression and a compact tokenizer loop, compiling down to roughly 1kb gzipped. It covers the common Markdown subset — bold, italics, strikethrough, ATX and Setext headings, blockquotes, ordered and unordered lists, inline and fenced code blocks, links (including reference-style), images, and horizontal rules — without implementing a full CommonMark-compliant engine.
It ships in ES module, CommonJS, and UMD formats built with microbundle, carries zero runtime dependencies, and targets size-constrained environments such as embedded editors, chat previews, or documentation widgets where pulling in a full Markdown library would be overkill. It intentionally does not sanitize its HTML output, so callers rendering untrusted input need to sanitize separately.
What You Get
- A single default-exported
parsefunction: pass a Markdown string in, get an HTML string back, with no configuration object required. - Support for the common Markdown subset: emphasis, strong, strikethrough, ATX and Setext headings, blockquotes, ordered/unordered lists, links (including reference-style), images, inline and fenced code blocks, and horizontal rules.
- Builds published as ES module, CommonJS, and UMD bundles via microbundle, plus a bundled TypeScript declaration file (
snarkdown.d.ts). - A roughly 1kb gzipped bundle with zero runtime dependencies, suitable for size-sensitive bundles.
Common Use Cases
- Rendering short, trusted Markdown snippets — comments, chat messages, changelog entries — in the browser without shipping a full parser.
- Powering lightweight in-browser Markdown editors and live-preview widgets.
- Embedding Markdown rendering in size-constrained contexts like browser extensions or bookmarklets.
Under The Hood
Architecture
The entire library is a single default-exported parse function in src/index.js implementing a hand-rolled, single-pass Markdown-to-HTML compiler built around one large composite regular expression executed in a loop via RegExp.exec, with a small explicit-stack context array (managed by the tag()/flush() closures) used to toggle open/close pairs for inline emphasis runs. Nested structures — list items, blockquotes, headings with inline links — are handled by recursive calls back into parse() itself rather than a separate AST layer, so lexing and HTML generation happen in the same loop body, chunk by chunk, instead of a two-stage parse-then-render pipeline. Changing the core tokenizer regex or the TAGS lookup table at the top of the file is effectively rewriting the whole engine, since nothing is decomposed into independently replaceable pieces — a deliberate trade-off in exchange for size.
Tech Stack
Plain ES6+ JavaScript with no runtime dependencies at all. Builds are produced with microbundle, emitting ES module, CommonJS, and UMD outputs plus a hand-maintained snarkdown.d.ts type declaration. Tests run under mocha and chai with @babel/register and a @babel/preset-env config to transpile the ES module test files, linting is configured via eslint-config-developit, and CI runs through GitHub Actions workflows. As a leaf utility package it has no server, database, or framework dependency of its own.
Code Quality
A real behavioral test suite in test/index.js exercises formatting, headings, links, images, lists, and blockquotes despite the terse implementation, and linting is wired into the test script. There is no internal type checking — the .d.ts file describes only the public surface, not the implementation — and naming inside the core function favors extremely terse single-letter variables (t, out, chunk) consistent with a minification-oriented style rather than a readability-oriented one. No error handling is present because none is needed: the function is a pure string transform with no I/O. Repository activity has been dormant since late 2022.
What Makes It Unique
Fitting a working Markdown grammar into roughly 1kb gzipped by encoding the entire tokenizer as one composite regular expression with numbered capture groups mapped to token kinds, and reusing a single delimiter-to-tag lookup table plus a shared stack to open and close both */_/~~ inline runs, is a distinctive, code-golf-adjacent parsing technique rarely seen in mainstream Markdown libraries, which typically separate block and inline passes over an explicit AST. It trades extensibility and CommonMark edge-case correctness for extreme minimality, which is exactly the niche it fills.
Used by 4 apps in this directory
DocuSeal
Digital Signiture
Open source document signing platform with WYSIWYG PDF builder, multi-party workflows, REST API, and full self-hosting via Docker.
GraphQL Hive
Developer Tools · Devops · Monitoring
Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.
Notesnook
Note Taking · File Storage · Security
End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.
OpenPanel
Hosting Control Panel · Devops
Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.