Socket
Book a DemoInstallSign in
Socket

quikdown

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quikdown

quikdown is a simple markdown to HTML parser that supports fences

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
120
-68.75%
Maintainers
1
Weekly downloads
 
Created
Source

quikdown

CI npm version Coverage Status License: BSD-2-Clause

Quikdown is a small, secure markdown parser with bidirectional conversion. Zero dependencies, XSS protection built-in, extensible via plugins for code highlighting and diagrams, and works in browser and Node.js.

For small and fast projects quikdown includes built-in inline styles for a "batteries included" rendering experience, but these can be overridden with themed css (see light and dark examples).

  • quikdown.js (9.0KB) - Markdown to HTML Parser
  • quikdown_bd.js (13.8KB) - Bidirectional (HTML ↔ Markdown) Parser
  • quikdown_edit.js (37.8KB) - Drop-in editor component (HTML ↔ Markdown) with md/split/html views

🚀 Live Demo | Editor Demo | Documentation

📍 Quick Links: InstallationQuick StartAPITypeScriptPluginsExamples

Features

  • 📦 Zero dependencies - No external libraries required
  • 🌐 Universal - Works in browsers and Node.js
  • 🚀 Lightweight - 9.0KB (core), 13.8KB (bidirectional), 37.8KB (editor)
  • 🔒 Secure by default - Built-in XSS protection with URL sanitization
  • 🎨 Flexible styling - Inline styles or CSS classes with theme support
  • 🔌 Plugin system - Extensible fence block handlers
  • Fast - Optimized regex-based parsing
  • 📝 CommonMark subset - Essential markdown features
  • Task Lists - GitHub-style checkboxes
  • 🔗 Autolinks - Automatic URL detection
  • 🔄 Bidirectional - Convert HTML back to Markdown (quikdown_bd)
  • 💬 Lazy linefeeds - Single newlines become line breaks (configurable)
  • 📱 Editor component - Drop-in markdown editor with live preview

Installation

Quikdown is available via NPM and related unpkg and jsdelivr

NPM package

npm install quikdown

CDN using UNPKG

CDN (ES Modules):

<script type="module">
  import quikdown from 'https://unpkg.com/quikdown/dist/quikdown.esm.min.js';
  document.body.innerHTML = quikdown('# Hello World');
</script>

CDN (UMD):

<script src="https://unpkg.com/quikdown/dist/quikdown.umd.min.js"></script>
<script>
  document.body.innerHTML = quikdown('# Hello World');
</script>

Quick Start

Quikdown is built in 3 versions. The smallest (quikdown) provides markdown to html conversion only. The next (quikdown_bd) provides markdown to html and html to markdown support. The lightweight editor quikdown_edit allows a bidirectional editor with lazy loading for common fences such as codeblocks, svg, and mermaid diagrams is also provided.

Markdown → HTML (quikdown.js)

// Basic conversion
const html = quikdown('# Hello World',
    {inline_styles: true}  // Use inline styles,  more options in API docs
);

document.body.innerHTML = html;

Bidirectional Markdown ↔ HTML (quikdown_bd.js)

// Convert with source tracking
const htmlString = quikdown_bd(markdown, options);

// Convert HTML back to Markdown
const markdown = quikdown_bd.toMarkdown(htmlString);

Note: quikdown does not provide a generic html to markdown conversion but uses special tags and limited DOM parsing for HTML to markdown conversion. Standard markdown components such as headings, text styles, tables, quotes, etc are supported. For custom fences quikdown relies on its tag system or 3rd party handlers to provide reverse (html to md) conversion.

Editor (quikdown_edit.js)

const editor = new QuikdownEditor('#container', {
  mode: 'split',           // 'source', 'split', 'preview' 
  theme: 'auto',           // 'light', 'dark', 'auto'
  plugins: { highlightjs: true, mermaid: true } // built-in fence handlers, see API docs for custom plugins
});

editor.setMarkdown('# Content  \nTo be quik or not to be.');  // provide default content
const content = editor.getMarkdown(); // get source content, see APIs for getting / setting HTML 

Other Configuration Options

quikdown supports built-in styles for a "batteries included" experience or you can bring your own CSS themes. Example css files are provided for basic light and dark themes to get started.

const html = quikdown(markdown, {
  lazy_linefeeds: true,    // Single newlines become <br>
  inline_styles: false,    // Use class based CSS instead of inline styles
  fence_plugin: {          // Custom code block processor (v1.1.0+ API)
    render: myHandler      // Function to render fence blocks
  }
});

Styling Options

Inline styles: All formatting uses inline CSS

quikdown('**bold**', { inline_styles: true });
// <strong style="font-weight: bold;">bold</strong>

Class-based styling: Uses CSS classes (default)

quikdown('**bold**');
// <strong>bold</strong>
// Requires CSS: .quikdown strong { font-weight: bold; }
// see included dist/quikdown.light.css or quikdown.dark.css

Fence Plugins

Quikdown provides a callback for all fenced text such as code blocks, math, svg etc.

Handle code blocks with custom languages:

const fencePlugin = {
  render: (code, language) => {
    if (language === 'mermaid') {
      // Process with mermaid library and return rendered diagram
      const id = 'mermaid-' + Math.random().toString(36).substr(2, 9);
      setTimeout(() => mermaid.render(id + '-svg', code).then(result => {
        document.getElementById(id).innerHTML = result.svg;
      }), 0);
      return `<div id="${id}" class="mermaid">Loading diagram...</div>`;
    }
    // Return undefined for default handling
  }
};

const html = quikdown(markdown, { fence_plugin: fencePlugin });

TypeScript Support

quikdown includes TypeScript definitions for better IDE support and type safety:

import quikdown, { QuikdownOptions, FencePlugin } from 'quikdown';

const fencePlugin: FencePlugin = {
  render: (content: string, language: string) => {
    return `<pre class="hljs ${language}">${content}</pre>`;
  }
};

const options: QuikdownOptions = {
  inline_styles: true,
  fence_plugin: fencePlugin
};

const html: string = quikdown(markdown, options);

Supported Markdown

Text formatting: **bold**, *italic*, ~~strikethrough~~, `code`

Headings: # H1 through ###### H6

Lists:

  • Unordered lists
  • Ordered lists
  • Task lists

Links: [text](url) and automatic URL detection

Code blocks:

console.log('syntax highlighting support via plugins');

Tables, blockquotes, horizontal rules - See documentation for complete syntax reference

API Reference

For complete API documentation, see docs/api-reference.md

Security

All HTML is escaped by default. Only safe markdown constructs become HTML:

const unsafe = '<script>alert("XSS")</script> **bold**';
const safe = quikdown(unsafe);
// &lt;script&gt;alert("XSS")&lt;/script&gt; <strong>bold</strong>

Framework Integration

Works with React, Vue, Svelte, Angular. See Framework Integration Guide for examples.

Limitations

For size and security, quikdown doesn't support:

  • Reference-style links
  • Footnotes
  • Definition lists

Note that raw html, svg, etc can be rendered using appropriate fences

<h1>My HTML Content</h1>
<p>Some HTML</p>

as long as an appropriate fence plugin is provided. See API docs for example or try out in quikdown_edit.js which has built-in support for HTML with XSS prevention.

License

BSD 2-Clause - see LICENSE.txt

Acknowledgments

  • Inspired by the simplicity of early markdown parsers
  • Built for the QuikChat project
  • CommonMark spec for markdown standardization

Support

Keywords

markdown

FAQs

Package last updated on 23 Aug 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.