Back to templates

Template details

reMarked.js

A client-side JavaScript library that converts HTML into Markdown, MIT licensed, designed for WYSIWYG editor integration.

About this template

reMarked.js is a client-side JavaScript library that converts HTML into Markdown, purpose-built for pairing with WYSIWYG editors that lack Markdown output.

What is reMarked.js?

reMarked.js is a client-side HTML-to-Markdown converter written in JavaScript and released under the MIT License. It takes a DOM element such as document.body as input and produces a Markdown string as output, entirely in the browser without server round-trips. The library was created by leeoniya and is positioned as a client-side equivalent to the server-side Markdownify project.

Key Features

  • Comprehensive configuration — over 20 options control heading style (setext or ATX with optional # suffixes), code block delimiters, list bullet style, horizontal rule character, indentation string, strong/emphasis characters, and more. You can switch h1_setext and h2_setext on or off to choose between underline headers and hash-mark headers.
  • GitHub Flavored Markdown output — gfm_del toggles strikethrough for del tags, gfm_tbls enables Markdown-extra tables, and tbl_edges shows or hides side edges on tables. A col_pre option supplies the column prefix for missing table headers.
  • Unsupported-tag handling — the unsup_tags option categorizes non-Markdown tags into ignore, inline, block, block2, block1c, and block2c behaviors, so script, style, iframe, canvas, and more are emitted the way you want, or not at all.
  • Tag remapping — tag_remap converts deprecated or variant tags to their modern equivalents, for example remapping i to em and b to strong.
  • Text normalization — trim_code trims whitespace inside pre/code blocks, nbsp_spc converts   entities to regular spaces, and br_only avoids using two trailing spaces as line break indicators.
  • WYSIWYG editor integration — the README names Redactor, TinyMCE, CKeditor, Loki, and CLeditor as target editors, enabling those HTML-based editors to export Markdown. span_tags and div_tags options let you keep ambiguous span and div elements as HTML tags in the output.

Who is it for?

  • WYSIWYG editor developers who want to add Markdown export to their HTML-based editors, since the library is built for direct integration with Redactor, TinyMCE, CKeditor, Loki, and CLeditor.
  • JavaScript developers working on browser-based conversion tools that need a fully client-side HTML-to-Markdown pipeline without posting content to a server.
  • Content teams publishing to static site generators that accept Markdown, because reMarked.js can convert an entire page body (via render(document.body)) to a portable Markdown draft.

What can you do with reMarked.js?

  • Plugin authors: Wire reMarked.js into an existing WYSIWYG editor and expose a "Copy as Markdown" button that returns the editor's content as clean Markdown.
  • Site administrators: Build a one-click exporter that takes a live page's DOM and generates the Markdown source for migration to a new platform.
  • Power users: Tune every output detail—heading underline style, bullet character, horizontal rule character, indentation string, and code fence style—so the generated Markdown matches your static site generator's preferred flavor.

How does reMarked.js work?

Include the reMarked.js script, create a new reMarked(options) instance with the configuration object of your choice, then call .render() on any DOM node to return a Markdown string. The options object is optional; sensible defaults cover common output styles, and the live demo at leeoniya.github.io/reMarked.js shows the converter in action.

Pricing

reMarked.js is MIT Licensed, so it is free to use, modify, and distribute, including in commercial projects.

Alternatives

Markdownify is a server-side HTML-to-Markdown converter written in PHP that inspired reMarked.js to move the conversion to the client.

FAQ

Is reMarked.js free?

Yes, reMarked.js is released under the MIT License, which permits free use, modification, and redistribution with no license fee or attribution requirement beyond preserving the copyright notice.

What input does reMarked.js take?

reMarked.js takes a DOM element—typically document.body or the content container of a WYSIWYG editor—and renders that element's HTML into a Markdown string. The library runs entirely in the browser.

Can reMarked.js output GitHub Flavored Markdown?

Yes. The gfm_del option enables strikethrough syntax for del tags, and gfm_tbls enables Markdown-extra table output. The tbl_edges option controls whether table side edges are rendered.

Which WYSIWYG editors work with reMarked.js?

The README specifically names Redactor, TinyMCE, CKeditor, Loki, and CLeditor as integration targets. The library's design is to sit alongside those editors and produce Markdown from their HTML content.

How do I customize the heading style?

Use the h1_setext and h2_setext options to underline H1 and H2 headings with setext syntax, or set them to false to force ATX hash-style headers. The h_atx_suf option adds a trailing # suffix to ATX headers.

screenshot of reMarked.js on template0.com