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

svelte-asciiart

v0.0.5

Published

[![](https://alexey.work/badge/)](https://alexey.work?ref=ascii-md)

Readme

svelte-asciiart

A Svelte 5 component for rendering ASCII art as scalable SVG with optional grid overlay and frame.

Installation

npm install svelte-asciiart

Usage

<script>
	import { AsciiArt } from 'svelte-asciiart';

	const text = `+----------+
|  Hello   |
|  World!  |
+----------+`;
</script>

<AsciiArt {text} />

Props

| Prop | Type | Default | Description | | ------------ | ---------------------------------------------------------------- | -------- | ------------------------------------------------------------- | | text | string | required | The ASCII art text to render | | rows | number | auto | Frame rows (content can overflow into the margin) | | cols | number | auto | Frame columns (content can overflow into the margin) | | grid | boolean | false | Draw grid lines for the full viewBox (frame + margin) | | cellAspect | number | 0.6 | Character cell width/height ratio | | gridClass | string | '' | CSS class for the grid lines <path> | | frame | boolean | false | Draw a frame <rect> around the frame area | | margin | number \| [number, number] \| [number, number, number, number] | 0 | Margin around the frame in grid cells (top/right/bottom/left) | | frameClass | string | '' | CSS class for the frame <rect> | | svg | SVGSVGElement \| null | bindable | Optionally bind the underlying <svg> element | | baseSize | number | 50 | Pixels per viewBox unit for intrinsic SVG size (for exports) | | ...rest | SVGAttributes<SVGSVGElement> | - | All other SVG attributes are forwarded to the <svg> element |

Grid Mode

Grid mode renders text character-by-character in a precise grid, useful for ASCII art that needs exact alignment:

<AsciiArt {text} grid frame margin={[1, 2]} gridClass="ascii-grid" frameClass="ascii-frame" />

<style>
	.ascii-grid {
		stroke: #90ee90;
		stroke-width: 0.03;
		opacity: 0.5;
	}
	.ascii-frame {
		stroke: #ffb366;
		stroke-width: 0.05;
	}
</style>

Exporting

The package provides utilities to export styled SVGs and PNGs:

import { exportSvg, exportSvgToPng } from 'svelte-asciiart';

// Export SVG with computed styles embedded as a <style> block
const svgMarkup = exportSvg(svgElement, {
  includeBackground: true,
  backgroundColor: '#f3f4f6'
});

// Export to PNG (returns data URL by default)
const pngDataUrl = await exportSvgToPng(svgElement, {
  includeBackground: true,
  backgroundColor: '#f3f4f6',
  scale: 2 // retina scale factor
});

// Export to PNG as Blob
const pngBlob = await exportSvgToPng(svgElement, { output: 'blob' });

The exportSvg function extracts computed styles from classed elements (e.g., gridClass, frameClass) and embeds them in the SVG, making it standalone and portable.

License

MIT