hcl2json

Crates.iohcl2json
lib.rshcl2json
version0.1.8
created_at2025-06-28 22:23:57.158034+00
updated_at2025-07-11 23:57:19.03452+00
descriptionCLI program for converting HCL to JSON
homepage
repositoryhttps://github.com/martinohmann/hcl-rs
max_upload_size
id1730166
size86,629
Martin Ohmann (martinohmann)

documentation

https://docs.rs/hcl2json/

README

hcl2json

Build Status crates.io License: Apache 2.0 License: MIT

CLI program for converting HCL to JSON.

Installation

cargo install hcl2json

Usage

Convert a file from stdin

cat file.hcl | hcl2json

Convert multiple files to JSON

hcl2json file.hcl other-file.tf

Note: When converting multiple files or directories hcl2json emits a JSON array. By passing --file-paths/-P the behaviour can be changed to produce a JSON map keyed by input file path.

Recursively convert files from a directory

hcl2json --glob '**/*.tf' dir/

Note: The command above is equivalent to hcl2json dir/**/*.tf but may have slightly better performance when there are hundreds of matching files.

Simplify and pretty-print

Simplify HCL expressions where possible and emit pretty-printed JSON:

hcl2json --simplify --pretty file.hcl

Similar tools

Contributing

Contributions are welcome! Please read CONTRIBUTING.md before creating a PR.

License

The source code of hcl2json is licensed under either of Apache License, Version 2.0 or MIT license at your option.

Commit count: 579

cargo fmt