Thanks to visit codestin.com
Credit goes to lib.rs

11 releases

Uses new Rust 2024

0.3.0 Jun 25, 2025
0.2.11 Oct 22, 2024
0.2.9 Sep 17, 2024
0.2.5 Jun 10, 2024
0.1.0 Apr 20, 2024

#251 in WebAssembly

Codestin Search App Codestin Search App Codestin Search App

681 downloads per month
Used in 2 crates

MIT license

275KB
3.5K SLoC

Parse ansi strings and convert them to html and svg formats

install

It is recommended to use npm, it will compress svg using svgo

npm i ansi2 -g
cargo binstall ansi2
cargo install ansi2 --features="cli"

usage

neofetch | ansi2 > ./neofetch.svg
neofetch | ansi2 --format=svg --theme=vscode > neofetch.svg

vitest bench --run | ansi2 --format=html --mode=light > bench.html
vitest bench --run | ansi2 --format=text > bench.txt
vitest bench --run | ansi2 --format=svg --mode=dark  | resvg - -c > bench.png
cat ./assets/ghostty.png | ansi2 -f=ans

ansi2

use ansi2::{Canvas};

let canvas = Canvas::new(s);
for row in canvas.pixels.iter() {
  for pixel in row.iter() {
      // draw pixel
  }
}

ansi2-wasm

npm i ansi2 -g

neofetch | ansi2 > ./neofetch.svg
neofetch | ansi2 --format=svg --theme=vscode > neofetch.svg

options

format

neofetch | ansi2 --format=html > neofetch.html
neofetch | ansi2 --format=svg > neofetch.svg

theme

vga / vscode / ubuntu

neofetch | ansi2 --format=svg --theme=vscode > neofetch.svg

font

neofetch | ansi2 --format=svg --font=./font.ttf > neofetch.svg

mode

dark / light

neofetch | ansi2 --format=svg --mode=dark > neofetch.svg

example

neofetch

vitest

Dependencies

~9–13MB
~252K SLoC