markdown-to-image: Render Markdown into Beautiful Poster Images

markdown-to-image: Render Markdown into Beautiful Poster Images

Summary

markdown-to-image is a versatile React component designed to transform Markdown content into visually appealing poster images. It supports various social media formats and offers features like customizable themes and one-click deployment for a web editor. This tool is ideal for creating shareable content from plain Markdown.

Repository Info

Updated on December 3, 2025
View on GitHub

Introduction

markdown-to-image is a powerful React component designed to transform your Markdown content into beautiful, shareable poster images. This versatile tool is perfect for creating engaging visuals for social media, quotes, cards, or any content you wish to present visually. It not only provides a robust component for integration into your projects but also includes a built-in web editor for easy online use and one-click deployment.

Installation

To integrate markdown-to-image into your React project, you can install it via npm, pnpm, or yarn.

Install with npm:

npm i markdown-to-image

Install with pnpm:

pnpm install markdown-to-image

Install with yarn:

yarn add markdown-to-image

Examples

React Component Usage

Here's a basic example of how to use the Md2Poster component and its subcomponents within your React application:

import 'markdown-to-image/dist/style.css'
import { Md2Poster, Md2PosterContent, Md2PosterHeader, Md2PosterFooter } from 'markdown-to-image'

// ...

const markdown = `
# AI Morning Updates
> On April 29th, what's the latest in the AI field that should be on your radar?
...
`

// ...

return (
  // ...
  <Md2Poster>
    <Md2PosterHeader>Poster Header</Md2PosterHeader>
    <Md2PosterContent>{markdown}</Md2PosterContent>
    <Md2PosterFooter>Powered by ReadPo.com</Md2PosterFooter>
  </Md2Poster>
  // ...
)

Using the Web Editor

For a quick and easy way to create posters without integration, you can use the official online web editor or deploy your own instance.

Official Web Editor: readpo.com

Deploy Your Own Web Editor with Vercel: Deploy Editor

Next.js SSR Example

When using frameworks like Next.js for server-side rendering (SSR), you might encounter ReferenceError: document is not defined. This can be resolved by employing dynamic components with next/dynamic:

// page.ts
import dynamic from 'next/dynamic'
const Editor = dynamic(() => import('@/components/Editor'), {
  ssr: false,
})
// Editor.tsx
import React from 'react'
import { Md2Poster, Md2PosterContent, Md2PosterHeader, Md2PosterFooter } from 'markdown-to-image'

function Editor() {
  const markdown = `
# AI Morning Updates
> On April 29th, what's the latest in the AI field that should be on your radar?

![image](https://imageio.forbes.com/specials-images/imageserve/64b5825a5b9b4d3225e9bd15/artificial-intelligence--ai/960x0.jpg?format=jpg&width=1440)
1. **Tech hiccups in AI car race: NTU team misses final** : Collaboration with UAE tech group faces technical challenges in international AI car race.
2. **AI complicates kids' online safety: Parents take charge** : Rapid AI evolution poses challenges, prompting parents to take active measures for children's safety.
3. **AI boom's secret winners: Companies fueling growth** : Investors find unique opportunities in stock market's AI boom, with certain companies driving progress.
4. **AI redefining automation in competitive market** : AI is no longer just a buzzword, as companies across industries deploy it for competitive edge.
5. **London private school introduces AI classes for children** : Leading school in London introduces AI lessons to help children adapt to evolving technology landscape.
6. **China utilizes supercomputer for AI training amid chip constraints** : Progress in leveraging supercomputers and domestic AI chips for training large language models in China.
7. **AI-Driven Age of New Media: Opportunities and Challenges** : CGTN panel discusses opportunities and challenges in the AI-driven age of new media.
8. **Apple rumored to resume OpenAI discussions for generative AI features** : Speculations suggest Apple may collaborate with OpenAI for generative AI features on upcoming iPhones.
9. **Tech tycoon's family office invests in AI for $10 billion fund** : Premji Invest to inject more funds into AI initiatives, supporting a $10 billion fund managed by Azim Premji.
10. **Banks embrace Cloud and AI for innovation and partnerships** : Banking industry shifts towards innovation, collaboration, and customer-centricity through adoption of Cloud and AI technologies.
  `

  return (
    <Md2Poster theme="SpringGradientWave" size="mobile">
      <Md2PosterHeader className="flex justify-between items-center px-4">
        <span>@Nickname</span>
        <span>{new Date().toISOString().slice(0, 10)}</span>
      </Md2PosterHeader>
      <Md2PosterContent>{markdown}</Md2PosterContent>
      <Md2PosterFooter className="flex justify-center items-center gap-1">any children</Md2PosterFooter>
    </Md2Poster>
  )
}

export default Editor

Why Use markdown-to-image?

This project offers a compelling solution for anyone looking to convert Markdown into visually appealing images. Key features include:

  • Social Media Optimization: Render Markdown as poster images specifically optimized for sharing on social platforms.
  • Customization: Utilize one built-in template with support for custom templates and choose from 9 pre-built customizable themes.
  • Easy Output: Copy the generated output directly as an image or as HTML code for pasting into emails and editors.
  • Quick Deployment: Benefit from one-click deployment options to platforms like Vercel for the integrated web editor.
  • Image Handling: An integrated image CORS proxy simplifies the insertion of online images into your posters.

Links