node-canvas

A Cairo-backed implementation of the HTML5 Canvas API for server-side rendering in Node.js.

Library
npm
v3.2.3
10,692 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
85 /100 Excellent
Development Activity 76
Maintenance 72
Community 92
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 87
Code Quality 85
Innovation 82
Learning Curve 78

node-canvas is an open-source library that brings the browser’s HTML5 Canvas API to Node.js, backed by the Cairo 2D graphics library instead of a browser engine. It implements Canvas, CanvasRenderingContext2D, Image, and ImageData with the same method signatures developers already know from front-end canvas code, so drawing, path, and pixel-manipulation code can run identically on the server.

Because it wraps native Cairo bindings through a C++ addon, node-canvas can render directly to PNG, JPEG, and PDF streams and supports optional GIF and SVG input via libgif and librsvg, without spinning up a headless browser. This makes it the standard choice in the Node ecosystem for server-side chart rendering, image manipulation pipelines, thumbnail generation, and any workload that needs Canvas-API drawing outside a DOM.

What You Get

  • A Canvas, CanvasRenderingContext2D, Image, and ImageData API matching the browser’s HTML5 Canvas spec
  • Direct output streams for PNG, JPEG, and PDF (createPNGStream, createJPEGStream, createPDFStream)
  • Pre-built binaries for macOS (x86/arm64), Linux (glibc), and Windows x86/64, with a source-build fallback via node-gyp
  • Optional GIF, SVG, and custom font support via libgif, librsvg, and Pango/Fontconfig
  • Full pixel-level access through getImageData/putImageData for image processing pipelines
  • A test suite with visual regression fixtures and Web Platform Test (WPT) conformance checks

Common Use Cases

  • Server-side chart and graph rendering for reports or social-share images without a headless browser
  • Generating PDF documents or thumbnails programmatically from Node.js backends
  • Image manipulation pipelines (resizing, compositing, watermarking) reusing browser-canvas drawing code
  • Rendering dynamic Open Graph / social preview images at request time
  • Running canvas-dependent front-end libraries (e.g. chart libraries) in a Node.js/SSR context

Under The Hood

Architecture — node-canvas is a native Node.js addon: the C++ layer (src/Canvas.cc, src/CanvasRenderingContext2d.cc, src/Image.cc) binds directly to Cairo’s drawing primitives and exposes them through N-API/NAN bindings (lib/bindings.js), while a thin JavaScript layer (lib/canvas.js, lib/context2d.js) reshapes those bindings into the exact method surface of the browser’s HTMLCanvasElement/CanvasRenderingContext2D, including stream helpers (lib/pngstream.js, lib/pdfstream.js, lib/jpegstream.js) not part of the browser spec but added for Node-specific output.

Tech Stack — Primarily JavaScript with a substantial native C++ core, built via node-gyp/binding.gyp against system Cairo, Pango, and libpng/libjpeg/giflib/librsvg; util/has_lib.js detects available system libraries at install/build time to conditionally enable JPEG/GIF/SVG support, and prebuilt binaries are distributed per-platform to avoid requiring a full native toolchain for most users.

Code Quality — The test/ directory contains extensive Jest-style specs (canvas.test.js, image.test.js, imageData.test.js, dommatrix.test.js, fontParser.test.js) plus a wpt/ subdirectory running Web Platform Tests for HTML5 Canvas conformance, and test/fixtures/test/public hold reference images for visual regression comparison — a notably rigorous test setup for a native addon, given the difficulty of testing pixel-exact rendering.

API Design — The library deliberately mirrors the standard browser Canvas API method-for-method (getContext('2d'), fillRect, drawImage, toDataURL), so any developer familiar with front-end canvas code can use it immediately with near-zero new API surface to learn; the main added complexity is platform-specific native-dependency installation (Cairo/Pango) when a prebuilt binary isn’t available for the target OS/arch.

Used by 10 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
99%
Apache 2.0

Codebuff

AI Code Assistants

12,842

An open-source AI coding assistant that coordinates specialized agents to edit your codebase from natural language — including Freebuff, a free, ad-supported version powered entirely by open-source models like DeepSeek and Kimi.

View details
85
Repo Health
71
Technical
67
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,166

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 4 days ago
TypeScript
96%
AGPL 3.0

Midday

Invoicing Finance · Productivity

15,042

All-in-one AI-powered business operations platform for freelancers and solo entrepreneurs to manage invoicing, time tracking, banking, and financial intelligence.

View details
53
Repo Health
78
Technical
67
Dependency
Built with
TypeScript 96%
Updated 3 months ago
Clojure
72%
MPL 2.0

Penpot

Design Tools

60,454

Open-source design platform with GPU-accelerated canvas, native design tokens, and MCP-powered AI workflows for teams that ship fast.

View details
91
Repo Health
83
Technical
73
Dependency
Built with
Clojure 72%
Updated 5 days ago
TypeScript
96%
MIT

Pi

AI Agents

109,828

An open-source, self-extensible agent harness and coding agent CLI — a modular runtime (agent core, unified multi-provider LLM API, TUI) with no built-in permission system by default, documented containerization patterns for sandboxing instead.

View details
88
Repo Health
73
Technical
74
Dependency
Built with
TypeScript 96%
Updated 5 days ago
TypeScript
80%
AGPL 3.0

Postiz

Automation · Social Media

36,421

The agentic social media scheduler — AI-powered content creation, 33-platform posting, and team workflows, all self-hosted.

View details
91
Repo Health
70
Technical
63
Dependency
Built with
TypeScript 80%
JavaScript 11%
Updated 6 days ago
TypeScript
89%
MIT

Prime Agent

AI Agents · AI Code Assistants · Developer Tools

21,340

An open-source coding and research agent built around a Recursive Language Model that treats context as variables and a persistent Python REPL as its only tool.

View details
85
Repo Health
89
Technical
70
Dependency
Built with
TypeScript 89%
Updated 4 days ago
TypeScript
64%
AGPL 3.0

Silex

Design Tools · No Code Platforms

2,986

Free, open-source visual website builder that exports clean HTML/CSS — no lock-in, no subscription, host anywhere

View details
89
Repo Health
68
Technical
67
Dependency
Built with
TypeScript 64%
Rust 15%
JavaScript 11%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers