syncfusion-react-markdown-converter
Implementing Syncfusion React Markdown Converter
The Syncfusion Markdown Converter is a lightweight utility that transforms Markdown-formatted text into clean, semantic HTML. It is typically used alongside the Syncfusion React Rich Text Editor (RichTextEditorComponent) in Markdown editing mode to provide a live preview of rendered content.
When to Use This Skill
- Convert Markdown text to HTML in a React application
- Display a live preview of Markdown content as the user types
- Configure conversion behavior (GFM support, line breaks, async mode, error suppression)
- Build a Markdown editor with HTML preview using
RichTextEditorComponentin Markdown mode - Integrate
MarkdownConverter.toHtml()with the Syncfusion React Rich Text Editor
Documentation and Navigation Guide
Getting Started
- React setup and project creation (Vite / CRA)
- Installing
@syncfusion/ej2-markdown-converterand@syncfusion/ej2-react-richtexteditor - CSS imports for the material3 theme
- Module injection (
MarkdownEditor,Toolbar,Image,Link,Table) - Running the application
Convert Markdown to HTML — toHtml API
MarkdownConverter.toHtml()method signature- Basic usage example (standalone, no editor required)
- Supported Markdown elements (headings, lists, tables, links, images, inline styles)
- Using the return value with
dangerouslySetInnerHTML
Configurable Options
MarkdownConverterOptionsinterfaceasync— asynchronous conversion for large contentgfm— GitHub Flavored Markdown support (default: true)lineBreak— convert single line breaks to<br>(default: false)silence— suppress errors on invalid Markdown (default: false)- Full example passing options to
toHtml()
Rich Text Editor Integration
- Markdown mode with
editorMode="Markdown" - Live preview using
created,change, andactionCompleteevents - Toolbar configuration for Markdown editing
MarkdownFormatterfor custom Markdown syntax- Custom preview toggle button (full preview pattern)
- Full working example with preview toggle
Quick Start
Install packages and wire up the converter in three steps:
1. Install packages:
npm install @syncfusion/ej2-markdown-converter
npm install @syncfusion/ej2-react-richtexteditor
2. Import CSS in src/styles.css:
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-richtexteditor/styles/material3.css';
3. Convert Markdown to HTML:
import { MarkdownConverter } from '@syncfusion/ej2-markdown-converter';
const markdown = '# Hello World\nThis is **Markdown** text.';
const html = MarkdownConverter.toHtml(markdown);
console.log(html);
// Output: <h1>Hello World</h1><p>This is <strong>Markdown</strong> text.</p>
Common Patterns
Pattern 1: Standalone Conversion (No Editor)
When you only need to convert a Markdown string to HTML without an editor UI:
import { MarkdownConverter } from '@syncfusion/ej2-markdown-converter';
const html = MarkdownConverter.toHtml(markdownString);
document.getElementById('preview')!.innerHTML = html as string;
Pattern 2: Live Preview on Keyup
Convert on every keystroke inside a Rich Text Editor textarea:
const markdownConversion = () => {
if (mdsource?.classList.contains('e-active')) {
const htmlPreview = rteObj.element.querySelector('#' + rteObj.getID() + 'html-view') as HTMLElement;
htmlPreview.innerHTML = MarkdownConverter.toHtml(
(rteObj.contentModule.getEditPanel() as HTMLTextAreaElement).value
) as string;
}
};
Pattern 3: Conversion with Options
Disable GFM and enable line-break conversion:
const html = MarkdownConverter.toHtml(markdownString, {
gfm: false,
lineBreak: true
});
Pattern 4: Side-by-Side Preview with Splitter
For a full editor + preview experience, use the Syncfusion Splitter component alongside the Rich Text Editor in Markdown mode. The preview pane is updated via updateValue() on every change event.
📄 Read: references/richtexteditor-integration.md for the full implementation.
Key Props / API
| API | Type | Default | Purpose |
|---|---|---|---|
MarkdownConverter.toHtml(content, options?) |
static method | — | Converts Markdown string to HTML |
options.async |
boolean | false |
Async conversion for large content |
options.gfm |
boolean | true |
GitHub Flavored Markdown support |
options.lineBreak |
boolean | false |
Single line breaks → <br> |
options.silence |
boolean | false |
Suppress errors on invalid Markdown |
More from syncfusion/react-ui-components-skills
syncfusion-react-grid
Implements Syncfusion React Grid component for feature-rich data tables and grids. Use this when working with data display, sorting, filtering, grouping, aggregates, editing, or exporting. This skill covers grid configuration, CRUD operations, virtual scrolling or infinite scrolling, hierarchy grids, state persistence, and advanced data management features for data-intensive applications.
120syncfusion-react-rich-text-editor
Implements the Syncfusion React Rich Text Editor (RichTextEditorComponent) from ej2-react-richtexteditor, supporting HTML (WYSIWYG) and Markdown editing. Use this skill for toolbar configuration, image/video/audio insertion, paste cleanup, AI assistant integration, emoji picker, slash menu, mentions, import/export Word/PDF, form validation, and source code view in React applications.
116syncfusion-react-themes
Use this skill when users need to apply themes, customize appearance, switch dark mode, use CSS variables, configure icons, or modify visual styling for Syncfusion React components. Covers icon library, size modes, and Theme Studio integration.
114syncfusion-react-common
Common utilities and features for Syncfusion React components. Use this skill when the user needs to implement animations, drag-and-drop, state persistence, RTL support, localization, globalization, security, templates, and advanced features for Syncfusion React components.
114syncfusion-react-scheduler
Implement Syncfusion React Scheduler component for calendar, event scheduling, and appointment management. Use this when building scheduling systems, calendar applications, booking systems, or time management interfaces. Covers all scheduler views (Day, Week, Month, Timeline, Agenda, Year), data binding, resource scheduling, recurring events, CRUD operations, drag-and-drop scheduling, customization, accessibility, and advanced features.
114syncfusion-react-treegrid
Implements Syncfusion React TreeGrid for hierarchical data with sorting, filtering, editing, exporting, paging, virtual scrolling, and advanced features. Supports configuration, CRUD, aggregates, templates, state persistence, and performance optimization in React applications.
112