> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# hatchmark render

> Turn a dashboard or one of its blocks into a PNG with hatchmark render: width, scale, theme and filters, the JSON result, which browser it uses and how exact it is.

`hatchmark render` turns a dashboard, or one block of it, into a PNG: a chart to drop into a chat,
a doc or a slide, or a whole page to attach to a report. The picture is the built page drawn by a
real browser, so it has the same fonts, colours and layout a reader sees at that width and theme.
Like every command it never asks questions and prints one line of JSON when an agent runs it.

```sh theme={null}
hatchmark render sales                                # the whole page, into sales.png
hatchmark render sales --block revenue_by_region      # one card, into sales.revenue_by_region.png
hatchmark render sales --theme dark --width 390       # the phone layout in dark mode
hatchmark render explorer --filter period=last_30_days --filter grain=day --out chart.png
```

## Options

| Option | Meaning |
| - | - |
| `<dashboard>` | The dashboard name, its file name under `dashboards/`. |
| `--block <id>` | Render only this block's card instead of the whole page. KPIs, charts, tables and maps all work. The card is cut out of the page at the size it has there. |
| `--out <file>` | Where to write the PNG, relative to `--cwd`. Defaults to `<dashboard>.png`, or `<dashboard>.<block>.png` with `--block`. Missing directories are created. |
| `--width <px>` | The browser window width in CSS pixels, 320 to 3840, default 1280. The page picks the same layout it picks in a browser that wide, so 390 gives the phone layout. |
| `--scale <n>` | Device pixels per CSS pixel, 1 to 4, default 2. A page 1280 wide at scale 2 is a PNG 2560 pixels wide, sharp on high-density screens. |
| `--theme <light\|dark>` | The colour theme, default `light`. |
| `--filter <id>=<value>` | Set a dashboard filter to the value the page URL would carry. Repeat it for several filters. See [Filters](#filters). |
| `--install-browser` | When no browser is found, download the Chromium headless shell once. See [The browser](#the-browser). |

A whole page is as tall as its content; the window height does not matter.

## Filters

`--filter` takes the same id and value as the dashboard's query parameter in the page URL, so
`--filter period=last_30_days` renders what `/explorer/?period=last_30_days` shows. The id is the
filter's `id` in the dashboard file (see [Dashboards](/docs/reference/dashboards.md)).

| Filter | Values |
| - | - |
| period | A preset the filter lists, such as `last_30_days`, or a custom range `<first>..<last>` of days, such as `2026-08-01..2026-09-30`, when it offers one. |
| grain | A grain key the filter lists, such as `day`, `week:sunday` or `month`. |
| segment | Segment names separated by commas, such as `americas,paid_marketing`, or an empty value for all rows. |

A browser silently falls back to the default for a value it does not know. Render refuses it
instead, with `HM0002` and the values the filter accepts, so an agent can correct the call.
Filters that are not set keep their defaults. The theme is always `--theme`: `theme` is the page's own
URL parameter, and no filter may use it as its id (`HM2050`).

## Output

Human output names the file and its size in pixels. JSON output has the
[diagnostic report](/docs/reference/diagnostics.md) fields, with any warnings from the build, plus:

```json theme={null}
{
  "format_version": "1",
  "ok": true,
  "error_count": 0,
  "warning_count": 0,
  "diagnostics": [],
  "path": "sales.revenue_by_region.png",
  "dashboard": "sales",
  "block": "revenue_by_region",
  "width": 1280,
  "scale": 2,
  "theme": "light",
  "filters": {},
  "pixel_width": 1636,
  "pixel_height": 732,
  "browser": { "source": "chromium-headless-shell", "version": "159.0.8154.6" }
}
```

`path` is relative to `--cwd` when the file is inside it. `block` is present only with `--block`.

## What it does

1. Loads and checks the project, then runs the dashboard's queries the way `hatchmark build` does,
   reusing results from the [build cache](/docs/guides/build.md#build-cache). Errors stop it before anything is
   drawn, with the same diagnostics and exit codes as build.
2. Renders the page `build` would write, with the same runtime and fonts, and serves it to the
   browser from memory. Nothing is written to `outDir`.
3. Opens the page at the width, scale and theme, applies the filters as the page does on load, waits
   for the fonts and for filters that redraw the page, and saves the screenshot.

## The browser

Render needs a Chromium-based browser and looks for one in this order:

1. The executable `HATCHMARK_BROWSER` names, such as a Chrome or Chromium binary. If it does not
   start, render stops with `HM0011` rather than trying another browser.
2. The Chromium headless shell in Playwright's browser cache, when it is already there
   (`~/Library/Caches/ms-playwright` on macOS, `~/.cache/ms-playwright` on Linux, or
   `PLAYWRIGHT_BROWSERS_PATH`).
3. An installed Google Chrome, then Microsoft Edge.

On most machines Chrome or Edge is already installed, and render downloads nothing. When none is
found it exits 3 with `HM0011`. Rerun with `--install-browser` to download the Chromium headless
shell once, about 106 MB on macOS and 132 MB on Linux. Render never downloads without that flag.

A browser draws pages, and Hatchmark pages are HTML and CSS around SVG charts. That is why render
uses one rather than an SVG rasterizer: a rasterizer can draw a chart's SVG but not the KPI cards,
tables, page grid or filter controls around it, so its pictures would not match the page. Driving the
browser adds about 14 MB to the install (`playwright-core`, with no browser inside).

## Accuracy

The test suite renders pages and cards with filters, themes and widths from 390 to 1440 pixels, and
compares each PNG with a screenshot of the page `build` wrote, opened in the same browser. This is
done twice, with the Chromium headless shell and with a full Chrome build through
`HATCHMARK_BROWSER`. The PNG must have exactly the browser's size, and at most 0.1% of its pixels may
differ by more than 24 of 255 on any colour channel. In practice none do.

Different browser builds draw text slightly differently, and on Linux the headless shell and full
Chrome place glyphs a fraction of a pixel apart. To match a particular browser exactly, point
`HATCHMARK_BROWSER` at it.

## Exit codes

| Code | Meaning |
| - | - |
| 0 | The PNG was written. Warnings are allowed. |
| 1 | Errors in your files, as in `build`. |
| 2 | Usage error: no or unknown dashboard, block or filter, a value out of range, or errors in `hatchmark.yaml`. |
| 3 | Environment problem: no browser to render with (`HM0011`), or a data file that does not exist. |
| 4 | Internal bug in Hatchmark, such as a page error or a page that does not finish drawing within 30 s. Please report it. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.