whatisgithub

What is hcl?

hashicorp/hcl — explained in plain English

Analysis updated 2026-06-26

5,771GoAudience · developerComplexity · 3/5LicenseSetup · moderate

In one sentence

A Go library implementing HCL, HashiCorp's configuration language used by Terraform and Vault, giving Go developers a structured config format with expression support and built-in validation.

Mindmap

mindmap
  root((HCL))
    What it does
      Config language
      Structured parsing
      Expression evaluation
    Formats
      Native HCL syntax
      JSON equivalent
    Features
      Variable support
      String interpolation
      Custom functions
      Validation
    Use Cases
      Terraform configs
      Go CLI tools
      Dev tool config
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a Go tool that reads structured HCL configuration files the same way Terraform does

USE CASE 2

Accept both hand-written HCL files and machine-generated JSON in the same Go app since they map to identical structures

USE CASE 3

Add expression support to config files so users can compute values and use string interpolation without writing code

USE CASE 4

Get built-in config validation and meaningful error messages in your Go app without building a parser from scratch

What is it built with?

Go

How does it compare?

hashicorp/hclopenark/orchestratorponzu-cms/ponzu
Stars5,7715,7625,760
LanguageGoGoGo
Setup difficultymoderatehardmoderate
Complexity3/54/53/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

This is version 2 which has an incompatible API with version 1, verify which version your project needs before importing.

Use and distribute freely, but changes to HCL itself must be shared under the same Mozilla Public License.

So what is it?

HCL is a configuration language created by HashiCorp, the company behind tools like Terraform and Vault. Its purpose is to give developers a clean, readable way to write configuration files for their tools, sitting somewhere between the simplicity of JSON or YAML and the full power of a programming language. The language has two forms that represent the same underlying data. The native syntax is designed to be written and read by people: it uses blocks, labels, and key-value pairs in a way that is more concise and expressive than JSON. The JSON form is designed for machine-generated configuration, and the two can be mixed freely since they map to the same internal structure. That means a tool can accept both hand-written HCL files and machine-generated JSON files and process them identically. HCL supports expressions inside configuration values, not just static strings or numbers. You can do arithmetic, use string interpolation to embed variable values, and call functions defined by the application. This lets configuration files express conditional or computed settings without becoming full programs. The application developer defines which variables and functions are available, so the scope of what configuration authors can do is controlled. The library is intended for Go developers who want to build their own tools with a structured configuration format. Rather than designing a format from scratch or accepting raw JSON, they use HCL to get built-in parsing, validation, and error messages. The application declares what structure it expects, and HCL checks that the configuration file matches and returns the parsed values. This is version 2, which has an incompatible API with version 1. HCL originated in HashiCorp's Terraform project and was later extracted into a standalone library. It is released as open source under the Mozilla Public License.

Copy-paste prompts

Prompt 1
Show me how to use the hashicorp/hcl Go library to parse a config file and extract typed values into a Go struct.
Prompt 2
How do I support both HCL native syntax and JSON config files in my Go CLI tool using the hashicorp/hcl v2 library?
Prompt 3
How do I define which variables and functions are available when evaluating expressions inside an HCL config file?
Prompt 4
Help me write a Go program that validates an HCL configuration file and returns helpful error messages for wrong or missing fields.
Prompt 5
How does HCL expression evaluation work in hashicorp/hcl and how do I expose custom functions to users writing config files?

Frequently asked questions

What is hcl?

A Go library implementing HCL, HashiCorp's configuration language used by Terraform and Vault, giving Go developers a structured config format with expression support and built-in validation.

What language is hcl written in?

Mainly Go. The stack also includes Go.

What license does hcl use?

Use and distribute freely, but changes to HCL itself must be shared under the same Mozilla Public License.

How hard is hcl to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is hcl for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.