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

initial-logo

v1.2.0

Published

Generate JavaScript/TypeScript style logo

Readme

initial-logo.js

🇺🇸 English | 🇯🇵 日本語

npm version

Generate JavaScript/TypeScript style logos (up to 2 characters inside a square) easily.

Features

  • 🎨 Customizable: Change colors, size, fonts, border radius, text anchor, and more.
  • 🌈 Gradients: Support for linear/radial gradient backgrounds and text.
  • 🔤 Custom Fonts: Load fonts from any URL or local file (WOFF2/TTF).
  • Lightweight: Zero dependencies for the core logic.
  • 🖼️ Multiple Formats: Generate SVG strings (core), or PNG/JPG/WEBP via the Node.js adapter.

Installation

bun add initial-logo
# or
npm install initial-logo

Usage

Generate SVG String

import { generateRawSvg } from 'initial-logo';

// Basic usage
const svgString = await generateRawSvg({
  text: 'TS',
  size: 100,
  textColor: '#ffffff',
  backgroundColor: '#3178c6',
});

// Use in an <img> tag via data URL
const dataUrl = `data:image/svg+xml;base64,${btoa(svgString)}`;

Gradient Example

const svgString = await generateRawSvg({
  text: 'GR',
  textColor: ['#ff0000', '#0000ff'],          // linear gradient text
  backgroundColor: ['#222222', '#444444'],    // linear gradient background
  textGradientType: 'linear',                 // 'linear' (default) | 'radial'
  backgroundGradientType: 'linear',
});

Node.js Adapter (PNG / JPG / WEBP)

import { generatePng, generateJpg, generateWebp } from 'initial-logo/adapters/node';

const pngBuffer  = await generatePng({ text: 'TS', backgroundColor: '#3178c6' });
const jpgBuffer  = await generateJpg({ text: 'JS', backgroundColor: '#f7df1e' }, 90);
const webpBuffer = await generateWebp({ text: 'DN', backgroundColor: '#000000' }, 90);

The Node.js adapter depends on sharp. It is included in the package dependencies.

CLI Usage

# Generate SVG (default output: initial-logo.svg)
npx initial-logo -t TS

# Customize colors and size
npx initial-logo -t JS -s 200 --textColor "#000000" --backgroundColor "#f7df1e" -o js-logo.svg

# Gradient
npx initial-logo -t GR \
  --textColor "#ff0000" --textColor "#0000ff" \
  --backgroundColor "#222222" --backgroundColor "#444444" \
  -o gradient.svg

# Export as PNG
npx initial-logo -t TS -o logo.png

# Rounded corners, custom font weight, text anchor
npx initial-logo -t TS -r 16 -w 700 -a bottom-right -o logo.svg

CLI Options

| Option | Alias | Description | Default | |---|---|---|---| | --text | -t | Logo text — up to 2 graphemes (required) | - | | --size | -s | Logo size in pixels | 100 | | --output | -o | Output path (.svg / .png / .jpg / .webp) | initial-logo.svg | | --textColor | -T | Text color — repeat for gradient | #ffffff | | --backgroundColor | -B | Background color — repeat for gradient | #000000 | | --textGradientType | | Text gradient type: linear | radial | linear | | --bgGradientType | | Background gradient type: linear | radial | linear | | --fontSource | -f | Font URL or local file path | Raleway 700 (jsDelivr) | | --fontSize | -F | Font size in pixels | Math.round(size * 0.525) | | --fontWeight | -w | Font weight | 700 | | --borderRadius | -r | Border radius in pixels | 0 | | --textAnchor | -a | Text anchor position (see below) | center | | --help | -h | Display help message | - |

--textAnchor values: top-left | top | top-right | left | center | right | bottom-left | bottom | bottom-right

API

generateRawSvg(options: LogoOptions): Promise<string>

Generates a logo as an SVG string. This is the primary export of the core library.

LogoOptions

| Property | Type | Default | Description | |---|---|---|---| | text | string | (Required) | Logo text — up to 2 graphemes (supports emoji, CJK, etc.). | | size | number | 100 | Size of the square in pixels. Must be a positive finite number. | | textColor | string \| string[] | '#ffffff' | Text color. Pass an array of 2+ colors for a gradient. | | textGradientType | 'linear' \| 'radial' | 'linear' | Gradient type for text. Applies only when textColor is an array. | | backgroundColor | string \| string[] | '#000000' | Background color. Pass an array of 2+ colors for a gradient. | | backgroundGradientType | 'linear' \| 'radial' | 'linear' | Gradient type for background. Applies only when backgroundColor is an array. | | fontSource | string \| ArrayBuffer | Raleway 700 (jsDelivr CDN) | Font URL or ArrayBuffer of a WOFF2/TTF font. | | fontSize | number | Math.round(size * 0.525) | Font size in pixels. | | fontWeight | string \| number | 700 | Font weight passed to the font renderer. | | borderRadius | number | 0 | Corner radius of the square in pixels. | | textAnchor | TextAnchorPosition | 'center' | Position of the text within the square. |

Node.js Adapter

Import from initial-logo/adapters/node.

generatePng(options: LogoOptions): Promise<Buffer>

generateJpg(options: LogoOptions, quality?: number): Promise<Buffer>

quality defaults to 90.

generateWebp(options: LogoOptions, quality?: number): Promise<Buffer>

quality defaults to 90.

Types

type TextAnchorPosition =
  | 'top-left' | 'top' | 'top-right'
  | 'left'     | 'center' | 'right'
  | 'bottom-left' | 'bottom' | 'bottom-right';

type GradientType = 'linear' | 'radial';

Development

# Install dependencies
bun install

# Start playground
bun run playground

# Run tests
bun run test

# Build
bun run build

Disclaimer

This tool is an unofficial project and is not affiliated with, endorsed by, or connected to Oracle, Microsoft, or the OpenJS Foundation. Users are solely responsible for the trademark and copyright compliance of any logos generated using this tool.

License

MIT