Parsing network CLI output with TextFSM, Genie and TTP
In short: Many devices still only offer CLI output for some information. Parsers convert that text into structured data, such as a list of dictionaries, which scripts can use reliably. TextFSM with the NTC templates collection covers many vendors and works directly in Netmiko. Cisco Genie offers thousands of parsers, and TTP uses readable templates. Where an API or model-driven interface exists, prefer it.
Why parse?
Searching CLI text with if "up" in output breaks when output formats change slightly or when "up" appears in an interface description. Parsing converts output into fields such as interface, ip_address and status, so your script compares values, not text.
TextFSM and NTC templates
TextFSM uses templates made of regular expressions and states. The community ntc-templates package provides templates for hundreds of commands on many platforms. Netmiko can use them directly:
from netmiko import ConnectHandler
device = {"device_type": "cisco_ios", "host": "10.0.0.1",
"username": "netops", "password": "secret"}
with ConnectHandler(**device) as conn:
interfaces = conn.send_command("show ip interface brief", use_textfsm=True)
for intf in interfaces:
if intf["status"] != "up":
print(intf["interface"], intf["status"])
Field names come from the template; print one result to see them, as they differ between templates and versions.
Cisco Genie
Genie, part of the pyATS framework, includes thousands of parsers for Cisco platforms and some others. Netmiko supports use_genie=True, or you can use pyATS directly. Genie output is nested dictionaries keyed by interface or neighbour.
TTP
Template Text Parser lets you write a template that looks like the output itself, with variables in double braces:
interface {{ interface }}
description {{ description | ORPHRASE }}
ip address {{ ip }} {{ mask }}
TTP is handy for parsing configuration sections and less common commands.
Choosing
- Common show commands on mainstream platforms: TextFSM with ntc-templates.
- Cisco-heavy environments and test automation: Genie.
- Configuration blocks or unusual output: TTP or a custom TextFSM template.
- Whenever possible: APIs, NETCONF, RESTCONF or gNMI, which return structured data directly.
Real-world example: the description that said "down"
A script flagged interfaces as down by searching for the word "down" in each line. It raised false alarms for an interface whose description was "Link to Downtown office". Switching to TextFSM parsing and checking the status field removed the false alarms.
Practice
Why is parsing better than searching CLI text for words?
How do you use ntc-templates with Netmiko?
When should you avoid parsing CLI at all?
Key takeaways
- Parsing turns CLI text into structured data.
- TextFSM with ntc-templates works directly with Netmiko.
- Genie offers many Cisco parsers; TTP uses readable templates.
- Prefer APIs and model-driven interfaces when available.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.