Architecture

WYSIWYG or Markdown input for your app?

What the writer sees and what you store are two separate choices. Pick the input for your users, the storage for your content, and sanitize either way.

5 min read

Teams often frame this as one choice: give users a WYSIWYG editor, or give them a Markdown box. It is really two choices. One is what the writer sees while typing. The other is what your application stores. You can answer them separately, and most of the trouble comes from answering them together.

Start with who writes

Markdown suits people who already know it: developers, technical writers, and anyone who writes in a code editor all day. They type quickly, keep their hands on the keyboard, and like that the text diffs cleanly. Everyone else has to learn a syntax before they can make a heading or a table. Support staff, customers, lawyers and teachers usually expect a toolbar and a page that looks like the result.

If your users are mixed, do not pick for the majority and leave the rest behind. A WYSIWYG editor that also accepts Markdown typing serves both: typing # and a space makes a heading, - and a space starts a list, and the toolbar is there for people who never learned the shortcuts.

Then look at the content

Markdown describes a small set of structures well: headings, paragraphs, lists, links, emphasis, quotes and code. It becomes awkward as soon as the content needs more. Tables with merged cells, coloured text, image sizes and alignment, comments, tracked changes and page layout have no standard Markdown form. Each tool invents its own extension, and those extensions do not travel between tools.

Storage is a separate decision

What the writer sees does not have to match what you store. A WYSIWYG editor can read Markdown, show it as rich text, and write Markdown back. That keeps your storage plain and easy to diff while the writer never sees the syntax.

Code example
// Load Markdown from storage, edit it as rich text, save Markdown again.
editor.fromMarkdown(storedMarkdown);
// ... the user edits ...
const markdown = editor.toMarkdown();

The limit is the same one as before. If the writer adds something Markdown cannot represent, the conversion has to drop it or fall back to inline HTML. Decide which before you ship, and test with real documents. If your content regularly needs those features, store HTML or a structured format instead; the guide to storing rich text compares the options.

Neither input is safe by default

A Markdown box feels safer than an HTML editor, but most Markdown parsers pass raw HTML through, and a link can carry a javascript: address in either format. Whatever the input is, sanitize the rendered HTML on the server before you store or display it. The stored XSS article covers what to check.

A short way to choose

For how the two-way conversion works in practice, see the WYSIWYG Markdown editor page.


RichTextEditor is a perpetual-licence JavaScript editor — one purchase, self-hosted, no metered editor loads. Download the evaluation or see how it compares.