# D3.js

> A free code tool for the web. You use it to build any chart you want.

**Field:** Design  
**Category:** Data Visualization  
**Also known as:** D3, Data-Driven Documents, D3 JavaScript Library

## Think of it like

It is like a box of LEGO bricks for charts. You can build any chart, but you build it piece by piece.

## Definition

D3.js is a free, open-source JavaScript library for building charts on the web. The name is short for data-driven documents. Mike Bostock created it in 2011. D3 ties data to the shapes on a web page, like SVG circles and lines. It gives no ready-made charts. It gives the parts, so a coder can build any chart, often with motion and clicks.

## Example

A news team builds an election map in D3. Readers hover over a county to see its vote count.

## Example code

```javascript
d3.select("svg")
  .selectAll("rect")
  .data([4, 8, 15])
  .join("rect")
  .attr("y", (d, i) => i * 22)
  .attr("height", 18)
  .attr("width", d => d * 10);
```

Three numbers become three bars. Each value sets one bar's width.

## Why it matters

It can draw charts no template offers. Many famous interactive news graphics were built with it.

## Common mistake

Picking it for a simple bar chart. A charting tool or a smaller library does that in minutes, not days.

## Three principles

- **Data drives shapes.** Values become SVG elements.
- **No templates.** You build each chart.
- **Web native.** SVG, Canvas and JavaScript.

## Related terms

- [JavaScript](https://learn.benibix.com/term/development/javascript)
- [Scalable Vector Graphics (SVG)](https://learn.benibix.com/term/design/scalable-vector-graphics)
- [Datawrapper](https://learn.benibix.com/term/design/datawrapper)
- [Flourish](https://learn.benibix.com/term/design/flourish)
- [Data Visualization](https://learn.benibix.com/term/design/data-visualization)

![Three panels. D3.js: three lines of code turn the numbers 4, 8 and 15 into three bars. Datawrapper: a small table of cities and rents, an arrow, and a bar chart headed Rents are highest in B. Flourish: three frames of a bar chart for weeks 1 to 3, with the bars changing length and order.](https://learn.benibix.com/diagrams/des6-viz-tools.svg)

---

Source: https://learn.benibix.com/term/design/d3js
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
