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

@meheduz/code-to-image

v1.0.0

Published

Transform code into beautiful shareable images

Downloads

38

Readme

code-to-image

npm version npm downloads License: MIT

Transform your code into beautiful shareable images — perfect for Twitter, LinkedIn, and blogs!

Quick Start

npx code-to-image myfile.js

Or with custom options:

npx code-to-image code.py --theme dracula --output screenshot.png

Features

  • 6 Beautiful Themes — Dracula, Monokai, GitHub, Nord, One Dark, Solarized Dark
  • Syntax Highlighting — 180+ languages with accurate per-theme color maps
  • Line Numbers — Toggle with --no-line-numbers
  • Auto-sizing — Perfect dimensions every time
  • Retina Ready--scale 1|2|3 for crisp output (default: 2x)
  • PNG Export — High-quality output
  • Fast — Generate in seconds
  • Social Media Ready — Optimized for sharing
  • macOS Window Style — Rounded corners, shadow, traffic-light controls
  • Cross-Platform — Works on macOS, Linux, Windows
  • Programmatic API — Use as a library in your own projects

Available Themes

| Theme | Style | Best For | |-------|-------|----------| | dracula | Dark purple | Twitter, Instagram | | monokai | Classic dark | GitHub, Dev.to | | github | Light | LinkedIn, Medium | | nord | Cool blue | Personal blogs | | one-dark | Atom-inspired | Clean dark look | | solarized-dark | Warm dark | Terminal lovers |

Usage Examples

Basic Usage

npx code-to-image app.js

Custom Theme

npx code-to-image code.py --theme monokai

Custom Output Name

npx code-to-image index.ts --output my-awesome-code.png

Specify Language

npx code-to-image script.txt --lang javascript

High-res Retina Output

npx code-to-image app.js --scale 3

Hide Line Numbers

npx code-to-image app.js --no-line-numbers

All Options

npx code-to-image file.js --theme one-dark --output result.png --lang typescript --scale 2

CLI Options

code-to-image <file> [options]

Options:
  --theme <name>      Theme (default: dracula)
                      dracula, monokai, github, nord, one-dark, solarized-dark
  --output <file>     Output filename (default: code-screenshot.png)
  --lang <name>       Force language for syntax highlighting
  --scale <number>    Resolution scale: 1, 2, or 3 (default: 2)
  --no-line-numbers   Hide line numbers
  --tab-size <n>      Tab width in spaces (default: 2)
  --help, -h          Show help
  --version, -v       Show version

Supported Languages

JavaScript, TypeScript, Python, Java, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Scala, HTML, CSS, SQL, Bash, and 160+ more!

Use Cases

  • Share code snippets on Twitter/LinkedIn
  • Add beautiful code examples to blog posts
  • Create programming tutorials
  • Include in presentations
  • Portfolio projects showcase
  • Documentation with visual examples

Installation

NPX (Recommended)

npx code-to-image file.js

Global Install

npm install -g code-to-image
code-to-image file.js

As a Library

npm install code-to-image
const { generateImage, themes } = require('code-to-image');

const png = generateImage({
  code: 'console.log("Hello, world!");',
  language: 'javascript',
  theme: 'dracula',
  fileName: 'hello.js',
  showLineNumbers: true,
  scale: 2,
});

fs.writeFileSync('output.png', png);

Contributing

Contributions welcome! Here's how:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/NewTheme)
  3. Commit changes (git commit -m 'Add new theme')
  4. Push to branch (git push origin feature/NewTheme)
  5. Open a Pull Request

Ideas for contributions:

  • Add new themes
  • Support more languages
  • Add custom fonts
  • Add watermark option
  • SVG / JPEG export formats
  • Custom background images

License

MIT © meheduz

Links