# Terraform vs Ansible: source lines of code compared

As of 2026-09-07, hashicorp/terraform contains 745,609 total lines (591,821 code) across 3,980 files, while ansible/ansible contains 166,997 total lines (126,700 code) across 871 files as of 2026-08-31. 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 | 3,980 | 871 |
| Total lines | 745,609 | 166,997 |
| Code lines | 591,821 | 126,700 |
| Comment lines | 73,091 | 15,064 |
| Blank lines | 80,697 | 25,233 |
| Languages counted | 12 | 11 |

Top languages in hashicorp/terraform: Go (92.8% of code), JSON (4.6% of code), HCL (2.3% of code). Top languages in ansible/ansible: Python (82.1% of code), YAML (11.6% of code), C# (2.9% 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 main (commit 7b8c301b55dd) on 2026-09-07; ansible/ansible was counted at ref devel (commit deecfd6e8c03) on 2026-08-31. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
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: 591,821 code lines versus 126,700 for ansible/ansible, about 4.7x as much, based on cached OctoCounts reports as of 2026-09-07.

### 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 main (commit 7b8c301b55dd) on 2026-09-07; ansible/ansible was counted at ref devel (commit deecfd6e8c03) on 2026-08-31. 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)
- [GitHub SLOC counter guide](https://octocounts.com/docs/github-sloc-counter)
- [Counting methodology](https://octocounts.com/docs/methodology)
- [OctoCounts API docs](https://octocounts.com/docs/api)
