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.
What opens 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.
Windows
- VS Code (HCL extension)
- any text editor
macOS
- VS Code (HCL extension)
- any text editor
Linux
- VS Code (HCL extension)
- any text editor
Open a .hcl file step by step
- Confirm the file really is a .hcl. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with VS Code (HCL extension) or any text editor.
- On Mac, use VS Code (HCL extension) or any text editor.
- On Linux, try VS Code (HCL extension) or any text editor.
- Still stuck? Convert the .hcl to json, which opens more widely.
Why can't I open my .hcl file?
Almost always because no installed app understands HCL. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .hcl at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
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 has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
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. How sources are ranked and what is deliberately left out is set out in the methodology.