A small, polished command-line tool that converts Markdown files into standalone HTML pages.
md2html supports common Markdown syntax, watches files for changes, highlights code with Light+ and Dark+ themes, and produces a complete HTML document with no external runtime assets.
Generated pages include syntax highlighting, line numbers, line hover states, one-click code copying, and a persistent light/dark theme switcher.
- Headings, paragraphs, ordered and unordered lists
- Links, images, blockquotes, tables, and fenced code blocks
- Syntax highlighting for code blocks and inline code
- Light+ and Dark+ themes that follow the system preference by default
- A theme switcher that remembers the reader's choice
- Code language labels, line numbers, line hover highlighting, and copy buttons
- A built-in responsive stylesheet with no external CSS or JavaScript files
- Watch mode for automatic conversion during editing
- Helpful CLI validation and error messages
- Node.js 18 or newer
- npm
Check your Node.js version with:
node --versionClone the repository and enter the project directory:
git clone https://github.com/dingZvel/md2html.git
cd md2htmlInstall the dependencies and compile the TypeScript source:
npm install
npm run buildYou can now run the compiled CLI directly:
node dist/index.js input.mdTo make the md2html command available globally from this source checkout, create an npm link:
npm linkAfter linking, the command can be used from any directory:
md2html input.mdTo remove the global link later:
npm unlink --global md2html-cliUsage: md2html <input.md> [-o output.html] [--watch]
Options:
-o, --output <file> Specify the output HTML file
-w, --watch Watch for changes and convert automatically
-h, --help Show help
-v, --version Show version
md2html notes.mdWhen no output is specified, the HTML file is written next to the input file using the same base name:
notes.md -> notes.html
md2html notes.md -o public/index.htmlThe long option works as well:
md2html notes.md --output public/index.htmlmd2html notes.md --watchThe first conversion runs immediately. Each time notes.md changes, the output file is generated again. Press Ctrl+C to stop watching.
Watch mode can be combined with a custom output path:
md2html notes.md -o public/index.html --watchUse the development command to execute the TypeScript source directly:
npm run dev -- sample.md -o sample.htmlOr run the compiled file after npm run build:
node dist/index.js sample.md -o sample.html# Project Notes
This paragraph contains a [link](https://example.com) and `inline code`.
- First item
- Second item
```typescript
const greeting: string = "Hello, Markdown!";
console.log(greeting);
```
Convert the bundled example and open the result in a browser:
md2html sample.md -o sample.htmlSee sample.md for a broader syntax example.
Each output file is standalone and contains:
- Semantic HTML generated from the Markdown source
- Embedded responsive page styles
- Embedded Light+ and Dark+ syntax colors
- Embedded theme-switching and code-copy behavior
- A page title based on the input filename
The generated page does not need this package or a web server to render. It can be opened directly from the filesystem.
# Run the TypeScript source
npm run dev -- sample.md
# Compile to dist/
npm run build
# Check TypeScript types without emitting files
npm run typecheck
# Run the compiled CLI
npm start -- sample.mdProject structure:
.
├── assets/ README images
├── dist/ compiled JavaScript
├── src/index.ts CLI and HTML renderer
├── sample.md example Markdown document
├── package.json
└── tsconfig.json
MIT
This tool was vibe coded using Codex with GPT-5.6-sol.

