snarkdown: The 1KB Markdown Renderer That Does Just Enough
I want to share a tiny markdown library I found: snarkdown. It’s 1KB and does just enough.
Most projects reach for Marked (50KB) or markdown-it (100KB). For displaying blog post summaries or user comments, you don’t need full CommonMark compliance. You need bold, italic, links, lists, code blocks. That’s it.
snarkdown is 1KB and renders exactly that.
What It Does (and Doesn’t)
Supports: bold, italic, strikethrough, links, lists, code blocks, headers. The basics.
**bold** and _italic_
[link](https://example.com)
`code`
- list item
# heading
Doesn’t support: tables, images, footnotes, reference-style links. If you need those, use Marked. If you don’t, why ship 50KB?
How to Use It
One function. Input markdown, get HTML:
import snarkdown from "https://esm.sh/[email protected]";
const markdown = "**Bold** and *italic* with [links](https://example.com)";
const html = snarkdown(markdown);
Load from CDN, no build step. Here’s how I use it in my newsletter digester:
import snarkdown from "https://esm.sh/[email protected]";
export default function Posts() {
return html`
<div dangerouslySetInnerHTML=${{ __html: snarkdown(post.summary) }} />
`;
}
AI-generated summaries come back with basic markdown. snarkdown renders them instantly.
My total frontend: Preact (3KB) + HTM (1KB) + snarkdown (1KB) = 5KB. Compare that to React + markdown-it = 275KB.
See it in action: github.com/mfyz/newsletter-blog-digester - check src/public/pages/Posts.js. One line of code. That’s it.
Related Posts
- 6 min readSmart client-side rendered Mermaid Charts on Astro Blogs
- 3 min readKokoro.js: Minimal Text-to-Speech API Model for In-Browser Use
- 2 min readOptimize your bundle size by eliminating dead code / tree-shaking in Webpack
- 5 min readUsing wp-rocket to speed up your wordpress site
- 5 min readdprint: The Rust-Based Code Formatter That's 10-100x Faster Than Prettier
- 5 min readReact's Best Parts in 5KB: Preact + HTM, No Build Tools Needed
Share