Pure SVG — No Canvas — No JS Runtime

GitHub Snake

An ultra-smooth, neon-glowing animated SVG snake that devours your GitHub contribution heatmap. Built with pure SMIL animation — works in <img> tags everywhere.

Node.js ≥18 ES Modules MIT License
Live Preview — DKN4Hackers
snake

Features

Everything that makes GitHub Snake stand out from the crowd.

Real Snake Path

Serpentine Hamiltonian path traverses all 53 × 7 = 371 contribution cells in a boustrophedon pattern.

Neon Glow + Trails

3-layer SVG filter stack with tight core glow, medium halo, and wide bloom — all animated seamlessly.

Heatmap Overlay

Contribution intensity (level 0–4) rendered as colored cells beneath the snake in real-time.

Gamified Ranking

6 tiers from Rookie to Legendary, shown as an animated hexagon badge based on your yearly contributions.

Multi-User Mode

Up to 4 snakes on the same grid, each phase-staggered around the loop with unique colors.

Ultra-Smooth

Pure SMIL SVG animation — no JavaScript, no Canvas, works in <img> tags everywhere.

Quick Start

Add this to your GitHub profile README.md (replace YOUR_USERNAME):

Markdown
<!-- Neon theme --> ![snake](https://git-hub-snake.vercel.app/api/snake?username=YOUR_USERNAME&theme=neon) <!-- Dark theme (GitHub default) --> ![snake](https://git-hub-snake.vercel.app/api/snake?username=YOUR_USERNAME&theme=dark) <!-- Cyberpunk --> ![snake](https://git-hub-snake.vercel.app/api/snake?username=YOUR_USERNAME&theme=cyberpunk)
HTML (Recommended)
<picture> <img src="https://git-hub-snake.vercel.app/api/snake?username=YOUR_USERNAME&theme=neon" alt="snake" /> </picture>

Live Preview

DKN4Hackers neon
DKN4Hackers
abdellahaarab cyberpunk
abdellahaarab

API Reference

Endpoint
GET /api/snake
Query Parameters
Parameter Type Default Description
username string — GitHub username (single-user mode)
users string — Comma-separated usernames, max 4 (multi-user mode)
theme string dark One of dark, neon, tokyo, cyberpunk, ocean

username and users are mutually exclusive. Use one or the other.

Examples

# Single user, neon theme /api/snake?username=DKN4Hackers&theme=neon # Single user, default dark theme /api/snake?username=torvalds # Multi-user — 3 snakes /api/snake?users=DKN4Hackers,torvalds,gvanrossum&theme=tokyo # Ocean theme /api/snake?username=DKN4Hackers&theme=ocean
Try it out:
https://git-hub-snake.vercel.app/api/snake?username=

Themes

5 handcrafted color palettes. Each theme provides 5 snake colors so multi-user snakes are always visually distinct.

dark
Dark

GitHub default palette

Background #0d1117
Empty cell #161b22
Snake #58a6ff
Max cell #39d353
neon
Neon

Deep black + electric colors

Background #000011
Empty cell #07071a
Snake #00ffff
Max cell #00aa50
tokyo
Tokyo

Tokyo Night editor theme

Background #1a1b26
Empty cell #24283b
Snake #7aa2f7
Max cell #4060cf
cyberpunk
Cyberpunk

Black + purple/magenta

Background #0a0010
Empty cell #100020
Snake #ff00aa
Max cell #8800cc
ocean
Ocean

Deep ocean blues and teals

Background #020c1b
Empty cell #0a1628
Snake #64ffda
Max cell #2d6fe0

Ranking System

Your rank is determined by your total GitHub contributions in the last year. It appears as an animated hexagon badge in the top-right of the SVG.

Tier Rank Threshold Color Badge
0 ROOKIE < 50 #667788 ·
1 BRONZE ≥ 50 #cd7f32 ▲
2 SILVER ≥ 200 #d0d0d0 ●
3 GOLD ≥ 500 #ffd700 ★
4 DIAMOND ≥ 1 000 #b9f2ff ◆
5 LEGENDARY ≥ 2 500 rainbow ✦

LEGENDARY gets a rainbow-animated gradient fill and cycling stroke color on the badge.

Multi-User Mode

Combine up to 4 GitHub profiles into one animated SVG. Each snake gets a unique color, evenly-spaced phase offset, and immediate visibility.

Usage
# Multi-user — 3 snakes on one grid /api/snake?users=DKN4Hackers,torvalds,gvanrossum&theme=tokyo # Full URL https://git-hub-snake.vercel.app/api/snake?users=DKN4Hackers,abdellahaarab&theme=neon
The heatmap always reflects the first user's contribution data. Stats in the footer also show the first user's numbers. Snake colors cycle from the theme's snakeColors array.
Multi-User Preview
multi-user

Self-Hosting

Run Locally
git clone https://github.com/DKN4Hackers/GitHub-Snake.git cd github-snake npm install npm start # → http://localhost:3000 # Custom port: PORT=4000 npm start
Deploy to Vercel
npm install -g vercel vercel # Then use your Vercel URL: ![snake](https://your-app.vercel.app/api/snake?username=YOUR_USERNAME&theme=neon)
Project Architecture
github-snake/ ├── api/ │ └── snake.js ← HTTP handler ├── lib/ │ ├── scraper.js ← GitHub HTML parser │ ├── snake.js ← Path builder + rank │ ├── svg.js ← SVG renderer │ └── themes.js ← Color definitions ├── utils/ │ └── cache.js ← In-memory cache ├── server.js ← Local dev server └── package.json
Data Flow
1 Request → api/snake.js
2 Cache check → utils/cache.js
3 Scrape → lib/scraper.js
4 Path + Rank → lib/snake.js
5 Render → lib/svg.js
6 SVG Response

How the Animation Works

Serpentine Path

The snake follows a boustrophedon (serpentine) Hamiltonian path through the 53 × 7 contribution grid:

col 0 ↓ col 1 ↑ col 2 ↓ col 3 ↑ … (0,0) (1,6) (2,0) (3,6) (0,1) (1,5) (2,1) (3,5) … … … … (0,6) (1,0) (2,6) (3,0)
Total path length 4 810 px
Animation cycle 30 seconds
Speed ≈ 160 px/s
3-Layer Neon Trail

Each snake is rendered as three stacked <path> elements sharing the same grid path:

LayerWidthOpacityDash
Outer glow10 px0.09390 4420
Inner glow6 px0.20260 4550
Snake body3 px1.00130 4680

Lag is implemented with negative SMIL begin offsets so trails are visible from the first frame.

Glowing Head

A <circle r="5.5"> follows the path with <animateMotion> + <mpath>, leading the body by exactly SNAKE_LEN / SPEED ≈ 0.811 s.

Two stacked feGaussianBlur passes (stdDeviation 2.5 and 8) create a dramatic flare effect.

Seamless Looping

stroke-dasharray is set so the pattern period equals the path length (dash + gap = 4810).

Animating stroke-dashoffset from 0 to -4810 over 30 s completes exactly one period → frame-perfect seamless loop.

SVG Filter Glow
<filter id="g0" x="-150%" y="-150%" width="400%" height="400%"> <feGaussianBlur in="SourceGraphic" stdDeviation="1.5" result="b1"/> <feGaussianBlur in="SourceGraphic" stdDeviation="5" result="b2"/> <feMerge> <feMergeNode in="b2"/> <feMergeNode in="b1"/> <feMergeNode in="SourceGraphic"/> </feMerge> </filter>
Stacking SourceGraphic on top of the blurred copies creates the classic neon look: bright solid core with a diffuse halo.

Caching

In-Memory Cache

Responses are cached in-memory for 30 minutes per username(s) + theme key. Cache is stored in utils/cache.js using a Map with auto-expiry via setTimeout.

HTTP Cache Headers

Downstream HTTP clients also receive:

Cache-Control: public, max-age=3600