Marked online editor

Write, Run & Share Marked code online using OneCompiler's Marked online editor for free. It's one of the robust, feature-rich online editors for Marked. Getting started with the OneCompiler's Marked online editor is really simple and pretty fast. The editor shows sample boilerplate code when you choose language as 'Marked' and start writing code to learn and test online without worrying about tedious process of installation.

About Marked

Marked is a fast Markdown parser for JavaScript. You give it a Markdown string and it returns HTML, which you drop into the page. It follows the CommonMark and GitHub Flavored Markdown rules, so headings, lists, tables, and code fences all work as expected.

Syntax help

Setup

Load Marked from a CDN. It exposes a global marked object with a parse method.

<textarea id="src"># Hello</textarea>
<div id="out"></div>
<script src="https://cdn.jsdelivr.net/npm/marked@14/marked.min.js"></script>

Parsing Markdown

marked.parse turns a Markdown string into an HTML string. Render it live by parsing on every keystroke.

const src = document.getElementById('src');
const out = document.getElementById('out');

function render() {
  out.innerHTML = marked.parse(src.value);
}

src.addEventListener('input', render);
render();

Options

Set options to control parsing. gfm enables GitHub Flavored Markdown, and breaks turns single newlines into line breaks.

marked.setOptions({
  gfm: true,
  breaks: true,
});

Inline parsing

parseInline returns HTML without wrapping it in a block element like <p>, which is useful for short snippets.

const html = marked.parseInline('Some **bold** and `code`.');

Custom rendering

marked.use lets you override how specific tokens render. Here every link opens in a new tab.

marked.use({
  renderer: {
    link(href, title, text) {
      return `<a href="${href}" target="_blank" rel="noopener">${text}</a>`;
    },
  },
});

Sanitizing output

Marked does not sanitize HTML, so untrusted Markdown can inject scripts. When the input isn't yours, run the output through a sanitizer such as DOMPurify before inserting it.

out.innerHTML = DOMPurify.sanitize(marked.parse(userInput));