hcledit
Command-line editor for HCL2 configuration files
TLDR
SYNOPSIS
hcledit [*global-flags*] *command*
DESCRIPTION
hcledit is a schemaless command-line editor for HCL2. It reads HCL from stdin (or -f), applies token-based edits that preserve comments, and writes the result to stdout (or updates in place with -u). It was built for Terraform-style refactoring but works for any HCL2 file without needing the target application binary.Operations cover attributes (get, set, append, rm, mv, replace), blocks (list, get, append, new, rm, mv), body extraction, and fmt.Install via Homebrew, release binaries, or make install from source.
PARAMETERS
attribute get|set|append|rm|mv|replace ...
Read or modify attributes by dotted address (for example resource.foo.bar.nested.attr).block list|get|append|new|rm|mv ...
Inspect or reshape blocks and labels.body get
Extract body content.fmt
Format HCL.-f, --file *path*
Input file (default - stdin).-u, --update
Write changes back to the file in place.
INSTALL
CAVEATS
HCL2 only (not HCL1). Schemaless parsing can be looser than application validation; always review diffs and run terraform validate (or equivalent) after bulk edits. Quote string values carefully when setting attributes from the shell.
