Free tech learning for everyone, from basics to pro

Network AutomationNetworking SecurityIntermediate

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.

Turning CLI output into dataRun commandshow ip intbriefRaw textalignedcolumnsParserTextFSM,Genie, TTPStructureddatalist of dictsUse itreports,checks
Figure 1. Parsing lets scripts work with values instead of fragile string searches.

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?
It produces structured fields, avoiding false matches and fragility when output changes.
How do you use ntc-templates with Netmiko?
Pass use_textfsm=True to send_command.
When should you avoid parsing CLI at all?
When an API or model-driven interface such as NETCONF, RESTCONF or gNMI provides the data in structured form.

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.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

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.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: