Convert HCL to JSON

Turn HCL files into JSON. Blocks nest by type and label as in the JSON form of HCL, and repeated blocks without labels become a list.

Converted in an isolated sandbox on our serversDeleted after 24 hours

Drop HCL files on the dialor turn it to pick what to do

Terraform files as plain JSON.Blocks nest by type and label. Expressions become text.

  1. What you get

    One JSON file from your HCL file. Blocks nest by type and label, as in the JSON form of HCL. Repeated blocks that have no labels become a list.

  2. How expressions are written

    References, function calls and type names become text in the form ${...}. An escaped ${ loses its escape in the output.

    Comments are dropped. If you need them, keep the original HCL file.

  3. When it fails

    If the file cannot be parsed, the conversion stops with input_corrupted. The HCL file itself has to be readable as HCL before it can become JSON.

    To go the other way, use JSON to HCL.

HCL and JSON.What each format is.

The formats

From · HCL

HCL

HashiCorp Configuration Language, what Terraform and Packer files are written in.

Extensions
.hcl .tf .tfvars
MIME type
application/x-hcl
Kind
Text and data
To · JSON

JSON

JSON, the data format of every API.

Extensions
.json
MIME type
application/json
Kind
Text and data

In your code.The same HCL to JSON conversion through the API, for your app or your agent.

terminal
$ cv convert report.hcl report.json
$ cv convert report.hcl report.json

Questions.What people ask about HCL to JSON.

01OF 04

Blocks nest by type and label, as in the JSON form of HCL. Repeated blocks without labels become a list.

They become text in the form ${...}. Type names are written the same way.

No. Comments are dropped from the JSON file.

The file could not be parsed. The conversion stops with input_corrupted when that happens.

More conversions.Other ways in and out of HCL and JSON.