Paste two lines into any page, use it from React, play it in a terminal, put a GIF in a README, or hand the Agent prompt to your coding agent. Every tab follows the look you pick above.
// npm install ascii-magic-art
import { useEffect, useRef } from "react";
import { play } from "ascii-magic-art/runtime/player.js";
import * as piece from "ascii-magic-art/pieces/heart-3d.js";
export function Heart3d() {
const ref = useRef(null);
// play() draws the piece on a canvas in your look and returns stop(), which React runs on unmount
useEffect(() => play(ref.current, piece), []);
return <pre ref={ref} style={{ fontSize: 10, fontFamily: "Menlo, Consolas, monospace" }} />;
}
npx ascii-magic-art heart-3d
<!-- Export the GIF below in the look you picked, commit it, then: -->
<p align="center">
<img src="assets/heart-3d.gif" alt="Heart 3D, animated ASCII art" width="720">
</p>
Add the animated ASCII art piece "heart-3d" (Heart 3D) from ASCII Magic to this project.
1. Load the script once, in the browser only (in SSR frameworks such as Next.js, load it on the client):
<script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script>
2. Put the piece where it fits best, such as the hero, a loading state, an empty state or the 404 page:
<ascii-art piece="heart-3d"></ascii-art>
3. Keep a real heading or text next to it (the art is decoration), and size it with the size attribute or CSS.
Preview and options: https://www.ascii-magic.com/ascii/heart-3d
Rules for coding agents: https://www.ascii-magic.com/ascii/use/ai-coding-agents
Export
Pause on the frame you like, pick a look, then download it at an exact size.
This ASCII heart is a solid 3D heart drawn in text characters that beats with a slow lub-dub rhythm and sways gently left and right, while a few small hearts float up behind it. Every frame is computed from a real heart-shaped surface, so the highlight slides across its two lobes as it turns. It plays on a grid of 64 by 30 characters at 30 frames per second.
If you only need a quick text heart, <3 and ♥ are covered just below. This page gives you something bigger: a drawn heart that moves. Pause it and press Copy as text to paste the current frame as plain text, embed it on a web page with one tag, or export a GIF, video or PNG for messages, Valentine's posts and wedding sites. Like every piece in the ASCII library, it is MIT licensed.
Quick text hearts versus a drawn ASCII art heart
The quickest text heart is <3, a less-than sign followed by the number 3, which reads as a heart lying on its side. Both characters are plain ASCII, so it works in any text field, message or code comment. The solid ♥ looks more like a real heart, but it is a Unicode symbol (U+2665, the heart suit from playing cards), not part of ASCII, which has only 128 characters. Most phones and computers show it, and in HTML you can write it as ♥.
An ASCII art heart is a different thing: a picture of a heart built from many characters across several lines, which is what most people mean when they look for an ASCII heart to copy and paste. This page draws one large, shaded heart and animates it. To take it as text, pause the player on a frame you like, press Copy as text, and paste it somewhere that uses a monospace font, such as a code block, a terminal or a plain text email, so the rows stay lined up. Only the characters come along, not the colors.
The big heart uses only ASCII characters: . : - = + * # % @, running from the dimmest edge to the brightest highlight.
The small drifting hearts are ♥ symbols. Delete them after pasting, or pick the ASCII look with Restyle text too switched on, and the whole copied frame is plain ASCII.
For a heart spelled in letters, type LOVE into Your characters, switch on Restyle text too, then copy the frame.
How this 3D heart animation is drawn
The shape comes from a classic heart surface equation, (x² + 2.25y² + z² - 1)³ - x²z³ - 0.1125y²z³ = 0, which describes every point where that formula equals zero. For each character cell, the code steps a ray forward from in front of the heart until it crosses into the surface, then halves the gap six times to pin down the exact point. It samples the formula at nearby points to work out which way the surface faces there.
That direction sets the brightness. A light from the upper left, in front of the heart, gives soft shading plus a small bright glint where the surface faces it most directly. Each brightness picks one of nine characters, from a faint period to a dense @, and one of 14 colors in a red ramp that runs from near black through crimson and pink to almost white. A depth test keeps the nearest surface in every cell, so the big heart always sits in front of the small ones.
The beat: one heartbeat every 1.3 seconds, about 46 a minute. Each beat is a strong pulse followed 0.28 seconds later by a softer one, the lub-dub, and the heart swells by up to 8 percent at the peak.
The turn: the heart sways around its vertical axis by up to about 43 degrees each way, and a full swing takes a little over 11 seconds. The light stays where it is, so the highlight glides across the lobes.
The background: 14 small ♥ symbols in two deep wine reds rise from the bottom at different speeds, swaying a little as they go, and start again at the bottom once they pass the top. The faster ones are slightly brighter.
Ways to use the animated heart
To put the heart on a web page, add <script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script> once, then an ascii-art tag with piece="heart-3d" where it should appear. Both lines are in the HTML tab. Attributes adjust it: size for the character size, speed="0.5" for a slower beat, bg for a background color, still for a single frame, and mono to draw it in one color that you set with CSS. It plays only while it is on screen, holds a still frame for visitors who prefer reduced motion, and weighs a few KB.
For a React project, the React tab gives a short component that draws the frames as text once you copy heart-3d.js and its helper kit.js into your project. The heart also plays in a terminal, in color: npx --yes ascii-magic-art heart-3d runs it, --frame prints one still frame and --seconds=3 stops it after three seconds. For a README, download the GIF, commit it and paste the snippet from the README tab.
Download GIF makes a short animated GIF for messages and posts. Download video gives MP4 or WebM at 1920x1080 by default, with a 4K option, and the PNG presets cover desktop wallpapers at 4K and 1080p, phone wallpapers, a 1280x720 thumbnail, banner and header sizes, square posts and stories. Before you export, try a look such as Halftone dots, Blocks, Dense ASCII or Numbers, or type your own characters. Because this heart is shaded with ordinary text characters, switch on Restyle text too so the look reaches the heart itself. Both Copy as text and the exports follow the look you choose.
An ASCII heart for Valentine's Day and other occasions
A heart that beats feels warmer than a static symbol, and it suits most of the moments people send hearts for. For other holidays, browse Occasions, and for more turning shapes, Solids.
Valentine's Day: send the GIF in a chat app, or post a story-size PNG with your own message written beneath it.
Anniversaries: pause on a frame where the heart faces you and export a phone wallpaper or a square image as a small gift.
Wedding sites: embed the heart above the date or the RSVP details, using mono with a color from your invitation and bg for a matching background.
Thank-you emails: put the GIF in the header, since email does not run scripts and cannot use the embed tag. For layouts, see ASCII art GIFs for newsletters and email.
Chat messages: <3 or ♥ for a quick note, the GIF for something bigger, or a copied frame pasted inside a code block so the rows line up. See ASCII art you can paste into Discord and Slack.
More hearts for these moments: Valentine Hearts fills the screen with shaded red and pink hearts floating up through a rose haze, and Voxel Heart builds a chunky heart from small red cubes that turns slowly with its own double beat.
Hearts for lessons and page design: Heart Blood Flow shows a four-chamber heart pumping blood to the lungs and body with every part labeled, and Heartbeat Rule sweeps a green heartbeat trace across the page as a divider.
/FAQS
Animated 3D ASCII Heart: frequently asked questions
Q. How do I copy and paste an ASCII heart?
Pause the Heart 3D player on a frame you like and press Copy as text, which copies that frame as plain text. Paste it where a monospace font is used, such as a code block, a terminal or a plain text email, so the rows stay lined up. Colors are not copied, only the characters.
Q. Is there a heart character in ASCII?
No, ASCII has no heart character, so the classic ASCII text heart is <3. ASCII's 128 characters cover letters, digits, punctuation and control codes. The solid ♥ is a Unicode symbol, U+2665, which you can write in HTML as ♥ or ♥, and most devices display it without trouble.
Q. What does <3 mean in a text message?
<3 is a text heart, a less-than sign and the number 3 that together look like a heart lying on its side. People use it to send love, thanks or support in messages and comments. Because both characters are plain ASCII, it displays correctly almost everywhere, even where symbols and emoji do not.
Q. How do I make a big heart out of text characters?
The easiest way is to copy a frame of this animated heart, which is already drawn in rows of text characters. Pause it, press Copy as text and paste it where a monospace font is used. To build the heart from your own characters, type them into Your characters, such as LOVE or a name, and switch on Restyle text too first.
Q. Can I download the ASCII heart as a GIF?
Yes, press Download GIF on this page to save a short animated GIF of the beating heart. It works well in chat apps, emails and Valentine's posts. Pick a look first if you want a different texture, and use Download video instead for an MP4 or WebM at 1920x1080 or 4K.
Q. How do I add an animated heart to my website?
Add one script tag to your page, then an ascii-art tag with piece="heart-3d" wherever the heart should appear. Both lines are ready to copy in the HTML tab. Use size to scale it, speed to slow the beat, bg for a background and mono to draw it in your own color. It pauses when scrolled off screen.
Q. How is this 3D heart animation made?
It is computed from a heart surface equation on every frame, not drawn frame by frame. For each character cell, the code steps forward until it meets the surface, works out which way the surface faces, and lights it from the upper left. The brightness picks a character from . to @ and a shade of red.
Q. Can I change the characters the heart is drawn with?
Yes, choose a look such as Halftone dots, Blocks, Binary or Numbers, or type your own characters, and switch on Restyle text too so the change reaches the heart itself. Copy as text and the GIF, video and PNG exports all follow the look you pick, so you can copy a heart made of the letters in a name.
Q. Can I send an animated heart in a chat app?
Yes, export the GIF and send it like any other image, since most chat apps play animated GIFs. For a text version, copy a frame and paste it inside a code block so the rows stay aligned. For a quick reply, <3 or ♥ still does the job.
Q. Can I use this heart on a wedding website or Valentine's card?
Yes, embed it on a wedding site with one tag, or export a square or story-size PNG for a digital card. Use mono with a color from your invitation and bg for the background so it matches the rest of the design. A GIF suits emailed save-the-dates and thank-you notes.
Q. Can I use the heart in commercial projects?
Yes, the heart is MIT licensed, so you can use it in personal and commercial work, including shop pages, Valentine's campaigns and ads. Credit is appreciated but not required. The JavaScript source is shown on this page if you want to change the colors, the beat or the speed of the turn.
Q. Are there other ASCII heart animations?
Yes, the library has several more pieces of heart ASCII art. Valentine Hearts fills the screen with floating red and pink hearts, Voxel Heart is built from small red cubes with a double beat, Heart Blood Flow shows a labeled four-chamber heart pumping blood, and Heartbeat Rule is a green heartbeat trace for use as a page divider.
MIT licensed and open source on GitHub. It imports one small helper file, kit.js. This is the animation itself: what gets drawn in every frame. The look you pick is applied on top by the player, like a filter, so this file stays the same in every look while the snippets above change with it. Edit it to change the animation; see the docs to make your own.
/* heart-3d: a solid 3D heart surface beating slowly and turning a little side to side. */
import { Grid, palette, gradient, KEYS, rng } from "../lib/kit.js";
/* tiny 3D kit for this piece: view space has +z away from the viewer. */
const LIGHT = (() => { const v = [-0.72, 0.55, -0.42], l = Math.hypot(v[0], v[1], v[2]); return [v[0] / l, v[1] / l, v[2] / l]; })();
/** Lambert plus a specular glint, 0..1, for a unit view-space normal. */
function lightOf(n, amb = 0.1, spec = 0.55, pw = 18) {
const d = n[0] * LIGHT[0] + n[1] * LIGHT[1] + n[2] * LIGHT[2];
const rz = 2 * d * n[2] - LIGHT[2];
const s = d > 0 && rz < 0 ? Math.pow(-rz, pw) : 0;
return Math.min(1, amb + Math.max(0, d) * (1 - amb) * 0.78 + s * spec * 0.6);
}
/** Filled triangle in screen cells with a depth test; points are [x, y, depth], larger depth is nearer. */
function tri(g, a, b, c, ch, co) {
const area = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
if (Math.abs(area) < 1e-6) return;
const x0 = Math.max(0, Math.floor(Math.min(a[0], b[0], c[0]))), x1 = Math.min(g.cols - 1, Math.ceil(Math.max(a[0], b[0], c[0])));
const y0 = Math.max(0, Math.floor(Math.min(a[1], b[1], c[1]))), y1 = Math.min(g.rows - 1, Math.ceil(Math.max(a[1], b[1], c[1])));
for (let y = y0; y <= y1; y++) for (let x = x0; x <= x1; x++) {
const px = x + 0.5, py = y + 0.5;
const w0 = ((b[0] - px) * (c[1] - py) - (b[1] - py) * (c[0] - px)) / area;
const w1 = ((c[0] - px) * (a[1] - py) - (c[1] - py) * (a[0] - px)) / area;
const w2 = 1 - w0 - w1;
if (w0 < -0.02 || w1 < -0.02 || w2 < -0.02) continue;
g.setZ(x, y, w0 * a[2] + w1 * b[2] + w2 * c[2], typeof ch === "function" ? ch(w0, w1, w2) : ch, co);
}
}
/** A depth-tested line between projected points, nudged toward the viewer by bias. */
function seg(g, a, b, ch, co, bias = 0) {
const n = Math.max(1, Math.ceil(Math.max(Math.abs(b[0] - a[0]), Math.abs(b[1] - a[1])) * 1.5));
for (let i = 0; i <= n; i++) {
const f = i / n;
g.setZ(a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f + bias, typeof ch === "function" ? ch(f) : ch, co);
}
}
/** Character for a line drawn in screen direction dx, dy (tall cells). */
function slopeChar(dx, dy) {
const a = Math.atan2(dy * 2, dx), s = Math.abs(Math.sin(a)), c = Math.abs(Math.cos(a));
if (s < 0.38) return "─";
if (c < 0.38) return "│";
return (dx > 0) === (dy > 0) ? "╲" : "╱";
}
const rx = ([x, y, z], a) => { const c = Math.cos(a), s = Math.sin(a); return [x, y * c - z * s, y * s + z * c]; };
const ry = ([x, y, z], a) => { const c = Math.cos(a), s = Math.sin(a); return [x * c + z * s, y, -x * s + z * c]; };
const rz = ([x, y, z], a) => { const c = Math.cos(a), s = Math.sin(a); return [x * c - y * s, x * s + y * c, z]; };
const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
const unit = (v) => { const l = Math.hypot(v[0], v[1], v[2]) || 1; return [v[0] / l, v[1] / l, v[2] / l]; };
/** Draw a mesh: V in view space, F as index lists (fans), each face lit flat. Normals face away from the origin when orient is set. */
function mesh(g, V, F, P, paint, edgeCo, orient = true) {
const S = V.map(P);
for (let f = 0; f < F.length; f++) {
const idx = F[f];
let n = unit(cross(sub(V[idx[1]], V[idx[0]]), sub(V[idx[2]], V[idx[0]])));
const c = [0, 0, 0];
for (const i of idx) { c[0] += V[i][0] / idx.length; c[1] += V[i][1] / idx.length; c[2] += V[i][2] / idx.length; }
if (orient && n[0] * c[0] + n[1] * c[1] + n[2] * c[2] < 0) n = [-n[0], -n[1], -n[2]];
const [ch, co] = paint(lightOf(n), f, n);
for (let i = 1; i + 1 < idx.length; i++) tri(g, S[idx[0]], S[idx[i]], S[idx[i + 1]], ch, co);
if (edgeCo) for (let i = 0; i < idx.length; i++) {
const a = S[idx[i]], b = S[idx[(i + 1) % idx.length]];
seg(g, a, b, slopeChar(b[0] - a[0], b[1] - a[1]), edgeCo, 0.012);
}
}
}
const RED = gradient(["#1f0306", "#5c0a14", "#a8142a", "#e8304a", "#ff8a9a", "#fff0f2"], 14);
export const meta = {
slug: "heart-3d",
name: "Heart 3D",
category: "solids",
note: "A solid 3D heart surface beating slowly with a lub-dub pulse, turning a little side to side as small hearts drift up behind it.",
tags: ["3d", "heart", "love", "valentine", "hero"],
cols: 64, rows: 30, fps: 30,
palette: palette([...RED, "#3a0d18", "#5a1626"]), // 0-d red, e f drifting hearts
};
const RAMP = ".:-=+*#%@";
// the classic heart surface; z is up, y is depth
const F = (x, y, z) => { const a = x * x + 2.25 * y * y + z * z - 1; return a * a * a - x * x * z * z * z - 0.1125 * y * y * z * z * z; };
export default function create() {
const { cols, rows } = meta;
const g = new Grid(cols, rows);
const cx = cols / 2, cy = rows / 2 - 0.5, SY = 11.5, SX = SY * 2;
const r = rng(5);
const drift = Array.from({ length: 14 }, () => [r() * cols, r() * 10, 0.6 + r() * 0.8]);
return (t) => {
g.clear();
for (const [x0, ph, sp] of drift) {
const y = rows - ((t * sp * 2 + ph * 3) % (rows + 4));
g.set(x0 + Math.sin(t + ph) * 2, y, "♥", sp > 1 ? "f" : "e");
}
const b = (t % 1.3);
const pulse = Math.exp(-((b / 0.1) ** 2)) + 0.55 * Math.exp(-(((b - 0.28) / 0.09) ** 2));
const s = 1 + 0.08 * pulse;
const th = Math.sin(t * 0.55) * 0.75, c = Math.cos(th), sn = Math.sin(th);
// object coords from view coords (X right, Y up, Z depth away)
const f = (X, Y, Z) => { const ox = (X * c - Z * sn) / s, oy = (X * sn + Z * c) / s, oz = Y / s; return F(ox, oy, oz + 0.08); };
for (let y = 0; y < rows; y++) {
const Y = (cy - y - 0.5) / SY;
if (Y < -1.25 || Y > 1.35) continue;
for (let x = 0; x < cols; x++) {
const X = (x + 0.5 - cx) / SX;
if (Math.abs(X) > 1.35) continue;
// march from the front until we enter the surface, then refine
let z0 = -1.3, hit = false;
for (let k = 0; k < 40; k++) {
const z1 = z0 + 0.065;
if (f(X, Y, z1) < 0) {
let lo = z0, hi = z1;
for (let m = 0; m < 6; m++) { const mid = (lo + hi) / 2; if (f(X, Y, mid) < 0) hi = mid; else lo = mid; }
z0 = hi; hit = true; break;
}
z0 = z1;
}
if (!hit) continue;
const e = 0.01, v = f(X, Y, z0);
const n = unit([f(X + e, Y, z0) - v, f(X, Y + e, z0) - v, f(X, Y, z0 + e) - v]);
const l = lightOf(n, 0.22, 0.9, 28);
g.setZ(x, y, -z0, RAMP[Math.min(8, Math.floor((0.12 + l * 0.88) * 9))], KEYS[Math.min(13, Math.floor((0.1 + l * 0.9) * 14))]);
}
}
return g.frame();
};
}