# Terraform vs Ansible: source lines of code compared

The Terraform vs Ansible comparison on OctoCounts shows side-by-side source line counts for hashicorp/terraform and ansible/ansible, counted with the same engine and analysis options on the dates shown in the methodology line: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.

As of 2026-09-16, hashicorp/terraform contains 749,354 total lines (595,101 code) across 4,021 files, while ansible/ansible contains 168,477 total lines (127,818 code) across 888 files as of 2026-09-13. hashicorp/terraform is about 4.7x the size of ansible/ansible by code lines. Code size is not code quality: a larger count only means more source material, not a better or worse project.

| Metric | [hashicorp/terraform](https://octocounts.com/github/hashicorp/terraform) | [ansible/ansible](https://octocounts.com/github/ansible/ansible) |
| --- | ---: | ---: |
| Files | 4,021 | 888 |
| Total lines | 749,354 | 168,477 |
| Code lines | 595,101 | 127,818 |
| Comment lines | 73,204 | 15,224 |
| Blank lines | 81,049 | 25,435 |
| Languages counted | 12 | 11 |

Top languages in hashicorp/terraform: Go (92.8% of code), JSON (4.5% of code), HCL (2.3% of code). Top languages in ansible/ansible: Python (81.8% of code), YAML (11.6% of code), C# (3.2% of code). Go, JSON, HCL, Protocol Buffers, Shell appear only in hashicorp/terraform's top languages; Python, YAML, C#, PowerShell, Jinja2 appear only in ansible/ansible's top languages.

Methodology: both counts come from cached OctoCounts reports generated with tokei. hashicorp/terraform was counted at ref f8e7458f5e427027f5b25e24a433c56f049aed3d (commit f8e7458f5e42) on 2026-09-16; ansible/ansible was counted at ref 5467293624690dbb5ecf8dc8f442fa3e3204fbc5 (commit 546729362469) on 2026-09-13. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
## About this comparison

hashicorp/terraform counts the Terraform core repository — the configuration language, state management, plan/apply engine, and built-in providers for its plugin protocol — while ansible/ansible counts the Ansible core: the automation engine, modules, and plugin machinery, with most content collections maintained in separate repositories. The two tools sit in adjacent but different categories, so the counts describe different kinds of software rather than two takes on one job.

The language tables show the implementation split directly: Terraform core is a Go codebase, while Ansible core is predominantly Python — each project's chosen language for its domain, visible without any inference from totals.

Ansible's count includes a large module and plugin surface inside the core repository, so its tree size partly reflects how much automation functionality ships from one repository rather than from a registry of collections.

_This is not a like-for-like tool comparison: Terraform provisions and manages infrastructure resources declaratively, Ansible automates configuration and tasks across machines. The line counts say nothing about which fits a given workflow._

Sources: [hashicorp/terraform repository](https://github.com/hashicorp/terraform) · [ansible/ansible repository](https://github.com/ansible/ansible). Statements verified 2026-09-16.

Evidence and next steps:

- [hashicorp/terraform SLOC report](https://octocounts.com/github/hashicorp/terraform)
- [ansible/ansible SLOC report](https://octocounts.com/github/ansible/ansible)
- [Compare hashicorp/terraform and ansible/ansible interactively](https://octocounts.com/compare?left=https%3A%2F%2Fgithub.com%2Fhashicorp%2Fterraform&right=https%3A%2F%2Fgithub.com%2Fansible%2Fansible)

Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.

## Compare FAQ

### Which has more lines of code, hashicorp/terraform or ansible/ansible?

hashicorp/terraform has more code: 595,101 code lines versus 127,818 for ansible/ansible, about 4.7x as much, based on cached OctoCounts reports as of 2026-09-16.

### Does more source lines of code mean more complexity?

Not necessarily. SLOC measures size, not complexity, quality, or maintainability. A larger codebase can mean more features, more generated or vendored code, more verbose language idioms, or more tests — none of which imply the code is harder to work with. Use SLOC to gauge the scale of what you'd be reading or maintaining, not as a quality signal for hashicorp/terraform, ansible/ansible, or any repository.

### How is this comparison calculated?

Methodology: both counts come from cached OctoCounts reports generated with tokei. hashicorp/terraform was counted at ref f8e7458f5e427027f5b25e24a433c56f049aed3d (commit f8e7458f5e42) on 2026-09-16; ansible/ansible was counted at ref 5467293624690dbb5ecf8dc8f442fa3e3204fbc5 (commit 546729362469) on 2026-09-13. See the counting methodology for ignored directories and analysis options.

### Can I compare a different branch, tag, or commit?

Yes. This page shows the default branch for each repository. Use the interactive comparison tool to pick any public GitHub repository, branch, tag, or commit SHA for both sides and get a fresh side-by-side report.

## Related OctoCounts pages

- [Interactive repository comparison](https://octocounts.com/compare)
- [Recently analyzed repositories](https://octocounts.com/recent)
- [Popular SLOC reports](https://octocounts.com/popular)
- [Trending GitHub repositories](https://octocounts.com/trending)
- [Hall of Monoliths](https://octocounts.com/hall-of-monoliths)
- [Original research: how filtering changes SLOC counts](https://octocounts.com/research)
- [GitHub SLOC counter guide](https://octocounts.com/docs/github-sloc-counter)
- [Counting methodology](https://octocounts.com/docs/methodology)
- [SLOC and code metrics glossary](https://octocounts.com/docs/glossary)
- [OctoCounts API docs](https://octocounts.com/docs/api)
