What is a .hcl file?
HashiCorp Configuration Language File · Code and data · HashiCorp · 2014
An .hcl file is written in the HashiCorp Configuration Language, a human-friendly config syntax of blocks and key = value pairs. Tools like Packer, Consul, Nomad and Vault use it; Terraform's .tf files are HCL too.
What is a .hcl file used for?
HCL was designed as a middle ground between JSON (machine-friendly, noisy for humans) and full scripting: it supports comments, expressions, variables and functions while staying declarative.
The extension varies by tool: Terraform names its HCL files .tf, Packer uses .pkr.hcl, Nomad .nomad or .hcl. Every HCL file also has an exact JSON equivalent for machine generation.
How to open a .hcl file
The .hcl format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .hcl file.
Windows
- VS Code (HCL extension)
- any text editor
macOS
- VS Code (HCL extension)
- any text editor
Linux
- VS Code (HCL extension)
- any text editor
How to convert a .hcl file
You can convert a .hcl file to json using a conversion tool or the export menu of an app that opens it.
.hcl file signature (magic bytes)
Programs recognise a .hcl file by the bytes at the start of the file, not by its name. These are the signatures for HCL.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .hcl file?
An .hcl file is written in the HashiCorp Configuration Language, a human-friendly config syntax of blocks and key = value pairs. Tools like Packer, Consul, Nomad and Vault use it; Terraform's .tf files are HCL too.
What uses .hcl files?
HashiCorp tools: Packer image builds, Nomad jobs, Consul and Vault configuration. Terraform uses the same language but names the files .tf.
Is HCL the same as JSON or YAML?
No, it is its own syntax with blocks and expressions, though every HCL file can be expressed in an equivalent JSON form. It is generally easier for humans to read than either.
How do I open an .hcl file?
Any text editor works; VS Code with an HCL extension adds highlighting. The file is only meaningful to the tool it configures.
Related formats
Sources
Details on this page were checked against authoritative references: