High-performance parser for Cisco show command output into structured data.
Network engineers spend enormous time manually reading and interpreting Cisco CLI output. ciscoparser takes raw show command text and converts it into clean, structured Python dictionaries — ready for automation, monitoring, auditing, or feeding into dashboards and APIs.
pip install ciscoparserOr install from source:
git clone https://github.com/cwccie/ciscoparser.git
cd ciscoparser
pip install -e ".[dev]"from ciscoparser import ShowCommandParser
raw_output = """
Codes: C - connected, S - static, O - OSPF
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 10.0.0.1
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
O 10.1.0.0/24 [110/20] via 192.168.1.2, 00:05:32, GigabitEthernet0/0
"""
parser = ShowCommandParser(raw_output, command="show ip route")
result = parser.parse()
for route in result["routes"]:
print(f"{route['prefix']:20s} via {route['next_hop']:20s} ({route['protocol']})")Output:
0.0.0.0/0 via 10.0.0.1 (static)
192.168.1.0/24 via directly connected (connected)
10.1.0.0/24 via 192.168.1.2 (ospf)
Don't know the command? ciscoparser auto-detects it from the output patterns:
parser = ShowCommandParser(raw_output)
result = parser.parse() # Automatically detects "show ip route"
print(result["command"]) # "show ip route"from ciscoparser import ShowCommandParser, to_json, to_yaml
parser = ShowCommandParser(raw_output, command="show version")
result = parser.parse()
print(to_json(result, indent=2))
print(to_yaml(result))ciscoparser includes a command-line interface:
# Parse a file and output JSON
ciscoparser parse router-output.txt
# Parse with explicit command and YAML output
ciscoparser parse router-output.txt --command "show ip route" --format yaml
# Detect what command produced the output
ciscoparser detect router-output.txt
# Verbose mode for debugging
ciscoparser -v parse router-output.txtMain parser class.
output(str): Raw CLI text from the Cisco device.command(str | None): Command name (e.g.,"show ip route"). Auto-detected if omitted.
Methods:
| Method | Returns | Description |
|---|---|---|
parse() |
dict |
Parse output into structured data. Raises ValueError if command unknown. |
detect_command() |
str | None |
Auto-detect command type from output patterns. |
Serialize parsed data to JSON string.
Serialize parsed data to YAML string.
| Command | Key Fields | Notes |
|---|---|---|
show ip route |
prefix, next_hop, interface, metric, protocol, ad, uptime | Handles ECMP multi-path, all protocol codes |
show interfaces |
name, status, protocol, ip_address, speed, duplex, mtu, counters | Input/output packets, errors, drops, rates |
show bgp summary |
neighbor, remote_as, state, prefixes_received, uptime | Also handles show ip bgp summary |
show bgp neighbors |
neighbor, remote_as, state, prefixes | Detailed neighbor output |
show version |
hostname, model, serial_number, ios_version, uptime, memory | IOS and IOS-XE formats |
show ip bgp |
network, next_hop, metric, local_pref, weight, as_path, origin | BGP table with status codes |
Every parsed result includes a command key indicating the detected/specified command:
{
"command": "show ip route",
"routes": [...],
"total_routes": 5
}All field names use snake_case for consistency.
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest -v
# Run tests with coverage
pytest --cov=ciscoparser --cov-report=term-missing
# Lint
ruff check src/ tests/MIT License. Copyright (c) 2026 Corey Wade.