README Generator
BeginnerPlatane/snk

How to Add Snake Contribution Animation to Your GitHub Profile README

The snake animation turns your GitHub contribution graph into an animated snake eating the green squares. It is the most-recognized GitHub profile widget — visitors notice it immediately and remember it. The animation is a pure SVG file generated by a GitHub Action and served from your repository, making it fast and reliable. This guide walks through configuring the Platane/snk GitHub Action, setting up automatic daily regeneration, and embedding the animation in your README with support for both light and dark mode.

Quick Setup Steps

  1. 1

    Step 1: Create .github/workflows/snake.yml in your GitHub profile repository.

  2. 2

    Step 2: Configure the Platane/snk@v3 Action with your username and two output paths (light and dark SVG).

  3. 3

    Step 3: Add permissions: contents: write to the workflow YAML.

  4. 4

    Step 4: Run the workflow manually from the Actions tab to generate the SVG files.

  5. 5

    Step 5: Add the <picture> element with both srcset paths to your README.md and commit.

What Is the Snake Contribution Animation?

The Platane/snk project generates an SVG animation that overlays a snake path on your GitHub contribution calendar. Each green square in your contribution history becomes a piece of food the snake eats as it moves across the grid. The result is a unique animated visualization of your commit activity that is both eye-catching and technically interesting.

Two versions are generated: one for light mode and one for dark mode. Using the HTML <picture> element with prefers-color-scheme, your README automatically serves the correct version based on each visitor's system preference. This means your profile looks great whether someone uses GitHub's light or dark theme.

How to Set Up the Snake Animation

Follow these steps to configure the GitHub Action:

  1. In your GitHub profile repository, create .github/workflows/snake.yml:
name: Generate Snake
on:
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch:
permissions:
  contents: write
jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
      - uses: Platane/snk@v3
        with:
          github_user_name: ${{ github.repository_owner }}
          outputs: |
            dist/github-contribution-grid-snake.svg
            dist/github-contribution-grid-snake-dark.svg?palette=github-dark
  1. Run the workflow manually from Actions → Generate Snake → Run workflow to generate the files.
  2. Add to your README:
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="dist/github-contribution-grid-snake-dark.svg">
  <source media="(prefers-color-scheme: light)" srcset="dist/github-contribution-grid-snake.svg">
  <img alt="snake" src="dist/github-contribution-grid-snake.svg">
</picture>

Customizing the Snake Animation

The snake color and background are configurable through the palette query parameter in the output path. The default generates a green snake on a light background. For a custom color scheme, you can specify colors directly: dist/snake-custom.svg?color_snake=orange&color_dots[]=0,0,0,15&color_dots[]=0,0,0,60&color_dots[]=0,0,0,85&color_dots[]=0,0,0,100.

The schedule runs at midnight UTC by default. You can change the cron expression to regenerate less frequently (weekly: 0 0 * * 0) or keep daily updates for profiles with consistent contribution activity. The generated SVG files are committed to the dist/ folder automatically by the Action — no manual steps needed after the initial setup.

Troubleshooting the Snake Animation

If the workflow fails with a permissions error, verify that the workflow has permissions: contents: write set in the YAML. GitHub's default workflow permissions changed in 2023 — older Action configurations that worked before may now require this explicit permission block.

If the snake renders but appears blank or shows no contribution data, check that the github_user_name input matches your exact GitHub username (case-sensitive). If the <picture> element shows both images stacked rather than switching, verify you are using raw GitHub content URLs — the dist/ path in the snippet above resolves correctly when the images are in your profile repository (username/username).

Frequently Asked Questions

How do I add the snake animation to my GitHub README?

Create a GitHub Actions workflow file at .github/workflows/snake.yml using the Platane/snk@v3 Action with two output paths (light and dark SVG), run it manually to generate the files, then embed the <picture> element with both srcset paths in your README. The animation regenerates daily via the cron schedule.

Is the snake GitHub README animation free?

Yes. Platane/snk is open source (MIT license) and uses only GitHub Actions compute, which is free for public repositories. There are no external services, API keys, or accounts required — the entire setup lives in your GitHub repository.

Why is my snake animation not showing up in my README?

The most common cause is that the SVG files haven't been generated yet. Run the workflow manually from the Actions tab. If it ran successfully, check that the file paths in your README match exactly where the Action committed the SVG files (default: dist/ folder in your repository root).

Does the snake animation work with private GitHub repositories?

The snake animation reads your public contribution data — the same data shown in your profile's contribution graph. Private repository contributions appear if they are counted in your public contribution graph (which requires the private contributions setting to be enabled in your GitHub profile settings).

From Our Blog

Generate Your GitHub Profile README

Generate a GitHub profile README featuring Snake Contribution Animation with AI

Try It Free — No Sign Up