npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

emoji-renderer

v0.1.0-rc.0

Published

Convert emoji to SVG markup or raster images with lazy-loaded Twemoji assets.

Readme

emoji-renderer

Convert emoji to SVG markup or raster images with lazy-loaded Twemoji assets.

Install

npm install emoji-renderer

Usage

import { emojiToSvg, emojiToImage } from "emoji-renderer";

const svg = await emojiToSvg("😀", { size: 48 });
const pixelSvg = await emojiToSvg("👾", { size: 96, pixelate: 8 });
document.querySelector("#target")!.innerHTML = svg;

const image = await emojiToImage("🎉", { size: 48 });
document.body.append(image);

Tree-shakable imports

Import only what you need:

import { emojiToSvg } from "emoji-renderer/emojiToSvg";
import { emojiToImage } from "emoji-renderer/emojiToImage";

Image output formats

emojiToImage defaults to an HTMLImageElement. Use format for other outputs:

const blob = await emojiToImage("😀", { format: "blob" });
const dataUrl = await emojiToImage("😀", { format: "dataUrl" });
const pixel = await emojiToImage("👾", { size: 96, pixelate: 8 });
const native = await emojiToImage("😀", { source: "native", size: 48 });
const responsiveSvg = await emojiToSvg("😀", { responsive: true });
const responsiveImg = await emojiToImage("😀", { size: 48, responsive: true });
const srcsetImg = await emojiToImage("😀", {
  size: 48,
  srcSet: [24, 48, 96],
  sizes: "(max-width: 600px) 24px, 48px",
  responsive: true,
});

Options

| Option | Applies to | Default | Description | | ---------------- | -------------- | ------------------ | -------------------------------------------------- | | size | both | 72 | Width and height in pixels | | source | both* | "twemoji" | "twemoji", "native", or { baseUrl, ext? } | | fetch | both | globalThis.fetch | Custom fetch implementation | | cache | both | true | Cache fetched SVG text in memory | | signal | both | — | AbortSignal for fetch | | xmlDeclaration | emojiToSvg | false | Prefix SVG with <?xml ...?> | | pixelate | both | off | Block size in px; >= 2 pixelates | | format | emojiToImage | "image" | "image", "blob", or "dataUrl" | | mimeType | emojiToImage | "image/png" | "image/png" or "image/webp" | | background | emojiToImage | null | Canvas fill color before drawing | | fontFamily | emojiToImage | emoji font stack | Font stack when source is "native" | | responsive | both | off | CSS-scalable SVG or retina raster display | | srcSet | emojiToImage | off | Logical widths for <img srcset> (format image) | | sizes | emojiToImage | — | Optional <img sizes> when srcSet is set |

* "native" applies to emojiToImage only. It draws the platform emoji font via canvas (no CDN fetch). Appearance varies by OS/browser.

Responsive output

SVG (true vector scaling):

const svg = await emojiToSvg("😀", { responsive: true });
// viewBox only — size with CSS: width: 2rem; height: auto;

const emSized = await emojiToSvg("😀", {
  responsive: { mode: "relative", width: "1.2em", height: "1.2em" },
});

Raster (retina + CSS display, or srcset):

const img = await emojiToImage("😀", { size: 48, responsive: true });

const srcsetImg = await emojiToImage("😀", {
  size: 48,
  srcSet: [24, 48, 96],
  sizes: "(max-width: 600px) 24px, 48px",
  responsive: { dpr: "auto", display: "css" },
});

responsive is incompatible with pixelate on emojiToSvg. srcSet requires format: "image".

Browser vs Node

This library is browser-first. SVG fetching works anywhere fetch is available. Rasterization requires a DOM with canvas support (document, Image, canvas or OffscreenCanvas).

For Node.js tests or scripts, use a DOM implementation such as happy-dom or jsdom.

Development

npm install
npm test
npm run test:browser
npm run build
npm run check
npm run build-storybook

Open demo/index.html with a local dev server to try conversions interactively, or run Storybook:

npm run storybook

Attribution

Emoji artwork is provided by Twemoji (CC-BY 4.0).

License

MIT