Render ASCII/ANSI terminal text as crisp, scalable SVG. A small family of packages:
-
lovely-ansi-svg— the framework-agnostic core:text → SVG string. Parses ANSI SGR escapes (16-color, 256-color, truecolor, attributes), lays glyphs out on a monospace cell grid (CJK/emoji width aware), and serializes themeable SVG. No DOM required — works in Node, SSR, workers, CI. -
svelte-asciiart— a thin Svelte 5 component over the core, with live font measurement and CSS-variable theming. -
lovely-svg-png— browser-side SVG-string → PNG rasterization with webfonts embedded asdata:URIs (follows@importchains, e.g. Google Fonts). Not ansi-specific.
Standalone SVG from any JS:
import { exportSvg } from 'lovely-ansi-svg';
const svg = exportSvg('\x1b[36mHello \x1b[1;33mANSI\x1b[0m world', {
frame: true,
margin: 1,
background: '#1e1e1e'
});Svelte component:
<script>
import { AsciiArt } from 'svelte-asciiart';
const text = `+----------+
| Hello |
| World! |
+----------+`;
</script>
<AsciiArt {text} />PNG in the browser:
import { exportSvg } from 'lovely-ansi-svg';
import { collectFontCss, svgStringToPng } from 'lovely-svg-png';
const svg = exportSvg(text, { fontFamily: '"JetBrains Mono", monospace' });
const fontCss = await collectFontCss('"JetBrains Mono"');
const blob = await svgStringToPng(svg, { fontCss, scale: 2, output: 'blob' });See each package's README for the full API.
MIT