Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

satori

> 前端框架
Open source

Enlightened library to convert HTML and CSS to SVG

13.7K stars0 likes2 views
WebsiteGitHub

About

Enlightened library to convert HTML and CSS to SVG

Satori: Enlightened library to convert HTML and CSS to SVG.

Note

To use Satori in your project to generate PNG images like Open Graph images and social cards, check out our announcement and Vercel’s Open Graph Image Generation docs →

To use it in Next.js, take a look at the Open Graph Image Generation examples →

Overview

Satori supports the JSX syntax, which makes it very straightforward to use. Here’s an overview of the basic usage:

javascript
// api.jsx
import satori from 'satori'

const svg = await satori(
  
,
  {
    width: 600,
    height: 400,
    fonts: [
      {
        name: 'Roboto',
        // Use `fs` (Node.js only) or `fetch` to read the font as Buffer/ArrayBuffer and provide `data` here.
        data: robotoArrayBuffer,
        weight: 400,
        style: 'normal',
      },
    ],
  },
)

Satori will render the element into a 600×400 SVG, and return the SVG string:

javascript
'<svg ...><path d="..." fill="black"></path></svg>'

Under the hood, it handles layout calculation, font, typography and more, to generate a SVG that matches the exact same HTML and CSS in a browser.


Documentation

JSX

Satori only accepts JSX elements that are pure and stateless. You can use a subset of HTML elements (see section below), or custom React components, but React APIs such as useState, useEffect, dangerouslySetInnerHTML are not supported.

Experimental: builtin JSX support

Satori has an experimental JSX runtime that you can use without having to install React. You can enable it on a per-file basis with @jsxImportSource pragmas. In the future, it will autocomplete only the subset of HTML elements and CSS properties that Satori supports for better type-safety.

typescript
/** @jsxRuntime automatic */
/** @jsxImportSource satori/jsx */

import satori from 'satori';
import { FC, JSXNode } from 'satori/jsx';

const MyComponent: FC<{ children: JSXNode }> = ({ children }) => (
  

)

const svg = await satori(
  <MyComponent>hello, world</MyComponent>,
  options,
)

Use without JSX

If you don't have JSX transpiler enabled, you can simply pass React-elements-like objects that have type, props.children and props.style (and other properties too) directly:

javascript
await satori(
  {
    type: 'div',
    props: {
      children: 'hello, world',
      style: { color: 'black' },
    },
  },
  options
)

HTML Elements

Satori supports a limited subset of HTML and CSS features, due to its special use cases. In general, only these static and visible elements and properties that are implemented.

For example, the <input> HTML element, the cursor CSS property are not in consideration. And you can't use <style> tags or external resources via <link> or <script>.

Also, Satori does not guarantee that the SVG will 100% match the browser-rendered HTML output since Satori implements its own layout engine based on the SVG 1.1 spec.

You can find the list of supported HTML elements and their preset styles here.

Images

You can use `` to embed images. However, width, and height attributes are recommended to set:

javascript
await satori(
  ,
  options
)

When using background-image, the image will be stretched to fit the element by default if you don't specify the size.

If you want to render the generated SVG to another image format such as PNG, it would be better to use base64 encoded image data (or buffer) directly as props.src so no extra I/O is needed in Satori:

javascript
await satori(
  ,
  // Or src={arrayBuffer}, src={buffer}
  options
)

CSS

Satori uses the same Flexbox layout engine as React Native, and it’s not a complete CSS implementation. However, it supports a subset of the spec that covers most common CSS features:

Property Property Expanded Supported Values Example
CSS Variables Supported, including --var-name declaration and var(--var-name) usage with fallback values Example
display flex, block, contents, none, -webkit-box, default to flex. Use flex, contents, or none for div elements with multiple child nodes.
position relative, static and absolute, default to relative
color Supported
margin
marginTopSupported
marginRightSupported
marginBottomSupported
marginLeftSupported
Position
topSupported
rightSupported
bottomSupported
leftSupported
Size
widthSupported
heightSupported
Min & max size
minWidthSupported except for min-content, max-content and fit-content
minHeightSupported except for min-content, max-content and fit-content
maxWidthSupported except for min-content, max-content and fit-content
maxHeightSupported except for min-content, max-content and fit-content
border
Width (borderWidth, borderTopWidth, ...)Supported
Style (borderStyle, borderTopStyle, ...)solid and dashed, default to solid
Color (borderColor, borderTopColor, ...)Supported
Shorthand (border, borderTop, ...)Supported, i.e. 1px solid gray
borderRadius
borderTopLeftRadiusSupported
borderTopRightRadiusSupported
borderBottomLeftRadiusSupported
borderBottomRightRadiusSupported
ShorthandSupported, i.e. 5px, 50% / 5px
cornerShape
Valuesround, squircle, square, bevel, scoop, notch, and superellipse()
Corner longhands (cornerTopLeftShape, cornerTopRightShape, ...)Supported
Side shorthands (cornerTopShape, cornerRightShape, ...)Supported. Corner shapes apply when the corresponding borderRadius is nonzero.
Flex
flexDirectioncolumn, row, row-reverse, column-reverse, default to row
flexWrapwrap, nowrap, wrap-reverse, default to nowrap
flexGrowSupported
flexShrinkSupported
flexBasisSupported except for auto
alignItemsstretch, center, flex-start, flex-end, baseline, normal, default to stretch
alignContentSupported
alignSelfSupported
justifyContentSupported
gapSupported
Font
fontFamilySupported
fontSizeSupported
fontWeightSupported
fontStyleSupported
fontFeatureSettingsSupported via HarfBuzz text shaping. Enables OpenType features like ligatures, small caps, stylistic sets, etc.
Text
tabSizeSupported
textAlignstart, end, left, right, center, justify, default to start
textIndentSupported, including negative values (hanging indent)
textTransformnone, lowercase, uppercase, capitalize, defaults to none
textOverflowclip, ellipsis, defaults to clip
textDecorationSupport line types underline and line-through, and styles dotted, dashed, double, solidExample
textShadowSupported
lineHeightSupported
letterSpacing

Issues· 157 open

View all issuesOpen on GitHub
  • #826

    Security: Incomplete fix in 0.33.5 for GHSA-wx4j-mvgx-mqwp — SVG animation elements bypass both controls

    Updated Oct 1, 2026
  • #820

    SVG viewBox containing a tab or line break is parsed as NaN

    Updated Sep 29, 2026
  • #818

    `transform: rotate()` throws for `turn` and `grad` units

    Updated Sep 29, 2026
  • #816

    `transform: none` throws "Failed to parse declaration"

    Updated Sep 29, 2026
  • #815

    letterSpacing: the space after a hyphenated word disappears ("LOW-COST PLAN" renders as "LOW-COSTPLAN")

    Updated Sep 28, 2026
  • #802

    0.33.0+ HarfBuzz: WOFF glyphs render as stacked horizontal bars (Inter Bold)

    Updated Sep 26, 2026
  • #801

    @vercel/og 1.0.2 aborts on import: bundled harfbuzz looks for ./hb.wasm, which the package does not ship

    Updated Sep 7, 2026
  • #799

    bug: [Playground] PDF (Satori + PDFKit) renders a blank preview for certain layouts

    Updated Sep 5, 2026
  • #484

    Using a `<span>` inside some text breaks wrapping

    Updated Aug 31, 2026
  • #791

    0.33 harfbuzzjs hb.wasm fails to resolve when satori is bundled (Next.js/Turbopack)

    Updated Aug 31, 2026

> Tags

TypeScriptcssimageimage-generationimage-generator

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架