Skip to content

Instantly transform any <canvas> and <video> into a dynamic grid of characters in real-time

What is textmode.js? โ€‹

textmode.js is a free, lightweight and framework-agnostic creative coding library for real-time ASCII art and textmode experiences in web browsers.

Transform any <canvas> or <video> element into dynamic ASCII representations with blazing-fast WebGL rendering. Whether you're using p5.js, three.js, or vanilla JavaScript, textmode.js seamlessly integrates with your existing projects to create interactive textmode games, live visual performances, and artistic installations.

For standalone projects, textmode.js provides its own p5.js-inspired drawing API, letting you create compelling ASCII experiences without additional dependencies. The library powers live coding performances, interactive installations, and digital art projects worldwide, bringing the nostalgic aesthetic of textmode art into modern web development.

Quick Start โ€‹

Get up and running with textmode.js in just a few steps:

  1. Install the library:
    bash
    npm install textmode.js

2a. Import and initialize with an existing <canvas> to capture:

javascript
import { textmode } from 'textmode.js';

// Reference your existing canvas element
const canvas = document.querySelector('canvas#myCanvas');
const textmodifier = await textmode.create(canvas);

2b. Import and initialize with an existing <video> to capture:

javascript
import { textmode } from 'textmode.js';

// Reference your existing video element
const video = document.querySelector('video#myVideo');
const textmodifier = await textmode.create(video);

2c. Import and use the standalone drawing API:

javascript
import { textmode } from 'textmode.js';

// Create a new textmodifier instance
const t = await textmode.create({
    width: window.innerWidth,
    height: window.innerHeight,
    fontSize: 16,
});

// Start drawing with the textmode API
t.draw(() => {
    t.background(128);
    t.fill(255);
    t.rect(50, 50, 200, 100);
});

Thatโ€™s it! Your canvas will now be displayed as real-time ASCII/textmode art.
For advanced usage and customization, see the API documentation.

Live Examples โ€‹

Experience textmode.js in action with our interactive demos:

p5.js (WEBGL)
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>
p5.js (P2D)
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>
hydra-synth
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>
Vanilla Canvas 2D
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>
Three.js
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>
Video
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>
Standalone
<!DOCTYPE html>
<html>
<head>
  <title>Parcel Sandbox</title>
  <meta charset="UTF-8" />
  <link rel="stylesheet" href="/styles.css" />
</head>
<body>
  <h1>Hello world</h1>
</body>
</html>

Community and Support โ€‹

Join our growing community of creative developers:

  • ๐Ÿ“š Documentation - Complete API reference
  • ๐ŸŽฎ Examples - Interactive demos and tutorials
  • ๐Ÿ› Issues - Bug reports and feature requests

Ready to Get Started? โ€‹

Transform your canvas into ASCII art in minutes. Check out our API documentation and examples to begin your textmode journey.