Generate Custom Reports from NetBox Without a Script
Use NetBox export templates to render custom CSV, JSON, or YAML reports directly from the web UI, with a worked device example and limits to watch for.
03 Oct 2025, 16:37 UTC

Pull data from NetBox without writing a script
You need a device list with site, role, and status for a spreadsheet. The NetBox REST API can provide it, but maintaining a Python client for a one-off report is overkill. Copying rows from the web table is slow and error-prone. NetBox export templates fill that gap: they render a filtered queryset directly from the web UI into CSV, JSON, or YAML using Jinja2 syntax.
How export templates work
An export template is a text template stored in NetBox and attached to one object type, such as dcim | Device or ipam | Prefix. When you run it, NetBox executes the template server-side against the current list-view queryset. Because the template can access related objects, you can emit fields across models—such as a device's site name or a prefix's VRF—without writing joins or API pagination code.
Jinja2 is a templating language that uses tags such as {% for ... %} and expressions like {{ variable }}. Here, queryset is the set of objects selected by your list filters, and object represents each item during iteration.
Worked example: device inventory CSV
This template renders a CSV of devices with name, device role, site, and status.
- In NetBox, go to Extensibility > Export Templates and create a new template.
- Set Content type to
dcim | Device. - Paste the template body below.
- Open the Devices list, apply your filters, and select the template from the export action.
- Inspect the preview pane, then download the file.
name,device_role,site,status
{% for object in queryset %}
{{ object.name }},{{ object.device_role.name if object.device_role else "" }},{{ object.site.name if object.site else "" }},{{ object.status }}
{% endfor %}
Field names and related-object accessors vary by NetBox version, so treat this as a starting point. If the preview raises an error, compare the attribute names against your instance's REST API response for the same object. To remove the template, delete it from Extensibility > Export Templates.
Limits and how to verify
Export templates render synchronously inside a web worker. A very large queryset can exhaust memory or time out, so scope templates to a filtered subset before downloading. Templates also lack native version control and scheduling; keep canonical copies in Git and trigger them manually or through the API.
To verify output, compare the rendered row count and sample rows against the REST API:
curl -s -H "Authorization: Token $NETBOX_TOKEN" \
"https://netbox.example.com/api/dcim/devices/?limit=0" | jq '.count'
Run this from a terminal using a read-only API token. Replace the hostname and token with your own. The API count should match the number of rows your template renders for the same filters. Avoid saving the token in shell history.
When to use the API instead
Use export templates for occasional, human-initiated reports that fit on a single page of results. Use the REST API or GraphQL for scheduled extracts, very large datasets, or pipelines that feed other systems. Templates make NetBox a lightweight data transformation layer, not a replacement for an extraction job.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.