A CLI utility that sorts Terraform variable, output, locals, and terraform blocks alphabetically and corrects spacing.
tfsort is a command-line utility that automatically sorts Terraform configuration blocks—such as variables, outputs, locals, and terraform sections—alphabetically within HCL files. It solves the problem of disorganized Terraform code by enforcing a consistent order and fixing spacing issues, making Infrastructure as Code (IaC) more readable and maintainable.
Terraform engineers, DevOps practitioners, and infrastructure developers who work with HCL files and want to automate code organization and formatting.
Developers choose tfsort for its simplicity, flexibility, and focus on Terraform-specific formatting. It offers recursive directory processing, dry-run previews, and support for multiple input/output methods without requiring complex configuration.
A CLI utility to sort Terraform variables and outputs
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically sorts variable, output, locals, and terraform blocks within HCL files, reducing manual effort and ensuring consistency, as highlighted in the key features.
Reads from files, directories, or stdin and writes to files or stdout, making it adaptable to various workflows, including CLI pipelines and batch processing.
Processes entire directories recursively while skipping version control (.git) and Terraform utility folders (.terraform), ideal for large codebases.
Allows previewing changes without modifying files using the -d flag, enabling safe experimentation and verification before commits.
Does not sort resource or data blocks, which are fundamental in Terraform, limiting its usefulness for comprehensive file organization.
Enforces alphabetical order without options for custom sorting rules, which may disrupt logical groupings or project-specific structures.
Lacks advanced configuration for custom exclusions beyond predefined directories, reducing flexibility in complex project setups.