ntc-templates โ parse CLI into structured data
A community library of TextFSM templates for hundreds of 'show' commands across Cisco, Arista, Juniper and more. Stop writing regex โ turn raw CLI output into clean, structured data.
Setup, key templates & run commands
Install ntc-templates. It ships the bundled TextFSM templates plus an index that maps vendor + command to the right template.
python3 -m venv .venv
source .venv/bin/activate
pip install ntc-templates textfsmThe simplest entry point: pass the platform, the command and the raw CLI text, and get back a list of dicts. The index picks the matching template automatically.
from ntc_templates.parse import parse_output
raw = open("show_ip_int_brief.txt").read()
rows = parse_output(
platform="cisco_ios",
command="show ip interface brief",
data=raw,
)
for row in rows:
print(row["intf"], row["ipaddr"], row["status"])Netmiko ships ntc-templates as its default TextFSM source. use_textfsm=True returns structured output directly off the wire.
from netmiko import ConnectHandler
device = {
"device_type": "cisco_ios",
"host": "10.10.1.1",
"username": "admin",
"password": "secret",
}
with ConnectHandler(**device) as conn:
rows = conn.send_command("show ip interface brief", use_textfsm=True)
print(rows) # list of dicts, parsed via ntc-templatesAdd a new parser by dropping a <vendor>_<command>.textfsm file under ntc_templates/templates/ and registering it in the 'index' file (regex command, platform, filename).
# 1. Create the template
# ntc_templates/templates/cisco_ios_show_foo.textfsm
#
# 2. Register it in ntc_templates/templates/index
# Template, Hostname, Platform, Command
# cisco_ios_show_foo.textfsm, .*, cisco_ios, sh[[ow]] foo
#
# Point NET_TEXTFSM at a custom template dir if needed:
export NET_TEXTFSM=/path/to/ntc_templates/templatesntc-templates uses raw/parsed fixture pairs under tests/. Run pytest to confirm a template parses sample output correctly before relying on it.
git clone https://github.com/networktocode/ntc-templates.git
cd ntc-templates
poetry install # or: pip install -r requirements.txt pytest
# run the full template test suite
pytest tests/ntc-templates is the parsing engine behind Netmiko's use_textfsm and many NetDevOps pipelines. Pair it with Netmiko or Nornir to collect and normalise device state at scale.